R set up

Script not shown in the HTML file.

Note that the data cleaning and exploration for this analysis is in a separate file called written by Hedyeh Ahmadi.

## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.1     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.2     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.1     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter()     masks stats::filter()
## ✖ dplyr::group_rows() masks kableExtra::group_rows()
## ✖ dplyr::lag()        masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## ------------------------------------------------------------------------------
## 
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## 
## ------------------------------------------------------------------------------
## 
## 
## Attaching package: 'plyr'
## 
## 
## The following objects are masked from 'package:dplyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
## 
## 
## The following object is masked from 'package:purrr':
## 
##     compact
## 
## 
## 
## Attaching package: 'scales'
## 
## 
## The following object is masked from 'package:purrr':
## 
##     discard
## 
## 
## The following object is masked from 'package:readr':
## 
##     col_factor
## 
## 
## 
## Attaching package: 'ggpubr'
## 
## 
## The following object is masked from 'package:plyr':
## 
##     mutate
## 
## 
## 
## Attaching package: 'matrixStats'
## 
## 
## The following object is masked from 'package:plyr':
## 
##     count
## 
## 
## The following object is masked from 'package:dplyr':
## 
##     count
## 
## 
## Loading required package: Matrix
## 
## 
## Attaching package: 'Matrix'
## 
## 
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## 
## 
## 
## Attaching package: 'nlme'
## 
## 
## The following object is masked from 'package:lme4':
## 
##     lmList
## 
## 
## The following object is masked from 'package:dplyr':
## 
##     collapse
## 
## 
## 
## Attaching package: 'lmerTest'
## 
## 
## The following object is masked from 'package:lme4':
## 
##     lmer
## 
## 
## The following object is masked from 'package:stats':
## 
##     step
## 
## 
## Loading required package: HLMdiag
## 
## 
## Attaching package: 'HLMdiag'
## 
## 
## The following object is masked from 'package:stats':
## 
##     covratio
## 
## 
## 
## Attaching package: 'Hmisc'
## 
## 
## The following object is masked from 'package:e1071':
## 
##     impute
## 
## 
## The following objects are masked from 'package:plyr':
## 
##     is.discrete, summarize
## 
## 
## The following objects are masked from 'package:dplyr':
## 
##     src, summarize
## 
## 
## The following objects are masked from 'package:xtable':
## 
##     label, label<-
## 
## 
## The following objects are masked from 'package:base':
## 
##     format.pval, units
## 
## 
## 
## Attaching package: 'doBy'
## 
## 
## The following object is masked from 'package:dplyr':
## 
##     order_by
## 
## 
## 
## Attaching package: 'rockchalk'
## 
## 
## The following object is masked from 'package:Hmisc':
## 
##     summarize
## 
## 
## The following objects are masked from 'package:e1071':
## 
##     kurtosis, skewness
## 
## 
## The following object is masked from 'package:plyr':
## 
##     summarize
## 
## 
## The following object is masked from 'package:dplyr':
## 
##     summarize
## 
## 
## 
## Attaching package: 'MASS'
## 
## 
## The following object is masked from 'package:rockchalk':
## 
##     mvrnorm
## 
## 
## The following object is masked from 'package:dplyr':
## 
##     select
## 
## 
## 
## Attaching package: 'psych'
## 
## 
## The following object is masked from 'package:Hmisc':
## 
##     describe
## 
## 
## The following objects are masked from 'package:scales':
## 
##     alpha, rescale
## 
## 
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
## 
## 
## corrplot 0.92 loaded
## 
## Loading required package: carData
## 
## 
## Attaching package: 'car'
## 
## 
## The following object is masked from 'package:psych':
## 
##     logit
## 
## 
## The following object is masked from 'package:dplyr':
## 
##     recode
## 
## 
## The following object is masked from 'package:purrr':
## 
##     some
## 
## 
## Loading required package: survival
## 
## 
## Attaching package: 'performance'
## 
## 
## The following object is masked from 'package:xtable':
## 
##     display
## 
## 
## 
## Attaching package: 'arsenal'
## 
## 
## The following object is masked from 'package:Hmisc':
## 
##     %nin%
## 
## 
## The following object is masked from 'package:matrixStats':
## 
##     iqr
## 
## 
## The following object is masked from 'package:scales':
## 
##     ordinal
## 
## 
## The following object is masked from 'package:lubridate':
## 
##     is.Date
## 
## 
## 
## Attaching package: 'NBZIMM'
## 
## 
## The following object is masked from 'package:psych':
## 
##     sim
## 
## 
## The following object is masked from 'package:stringr':
## 
##     fixed
## 
## 
## 
## Attaching package: 'philentropy'
## 
## 
## The following objects are masked from 'package:psych':
## 
##     distance, manhattan, minkowski

Importing the Clean Data

HEI_Aim2_Long <- read.csv("HEI_Aim2_Long.csv")
HEI_Aim2_Wide <- read.csv("HEI_Aim2_Wide.csv")

HEI_Aim2_Long_1KidPerFamily <- read.csv("HEI_Aim2_Long_1KidPerFamily.csv")
dim(HEI_Aim2_Long)
## [1] 30419    56
dim(HEI_Aim2_Wide)
## [1] 11866   140
dim(HEI_Aim2_Long_1KidPerFamily)
## [1] 25125    56
names(HEI_Aim2_Long)
##  [1] "X"                               "subjectid"                      
##  [3] "rel_family_id"                   "abcd_site"                      
##  [5] "eventname"                       "rel_relationship"               
##  [7] "interview_date"                  "demo_l_p_select_language___1"   
##  [9] "cbcl_select_language___1"        "rel_group_id"                   
## [11] "rel_ingroup_order"               "rel_same_sex"                   
## [13] "reshist_addr1_pm252016aa"        "sex"                            
## [15] "interview_age"                   "race_ethnicity"                 
## [17] "high.educ"                       "reshist_addr1_adi_perc"         
## [19] "reshist_addr1_adi_wsum"          "overall.income.b"               
## [21] "overall.income.l"                "overall.income.alltp"           
## [23] "prnt.empl.bl"                    "prnt.empl.l"                    
## [25] "prnt.empl.alltp"                 "neighb_phenx_avg_p"             
## [27] "neighb_phenx_sum_p"              "reshist_addr1_popdensity"       
## [29] "reshist_addr1_proxrd"            "married"                        
## [31] "married.or.livingtogether"       "cbcl_scr_syn_internal_r"        
## [33] "cbcl_scr_syn_external_r"         "cbcl_scr_syn_totprob_r"         
## [35] "cbcl_scr_syn_anxdep_r"           "cbcl_scr_syn_withdep_r"         
## [37] "cbcl_scr_syn_attention_r"        "cbcl_scr_syn_rulebreak_r"       
## [39] "cbcl_scr_syn_aggressive_r"       "cbcl_scr_syn_internal_t"        
## [41] "cbcl_scr_syn_external_t"         "cbcl_scr_syn_totprob_t"         
## [43] "cbcl_scr_syn_anxdep_t"           "cbcl_scr_syn_withdep_t"         
## [45] "cbcl_scr_syn_attention_t"        "cbcl_scr_syn_rulebreak_t"       
## [47] "cbcl_scr_syn_aggressive_t"       "reshist_addr1_years"            
## [49] "income_midp"                     "demo_comb_income_v2"            
## [51] "reshist_addr1_no2_2016_aavg"     "reshist_addr1_o3_2016_annavg"   
## [53] "reshist_addr1_pm252016aa_bl"     "reshist_addr1_no2_2016_aavg_bl" 
## [55] "reshist_addr1_o3_2016_annavg_bl" "high.educ_bl"
names(HEI_Aim2_Wide)
##   [1] "X"                                    
##   [2] "subjectid"                            
##   [3] "rel_family_id"                        
##   [4] "rel_group_id"                         
##   [5] "rel_same_sex"                         
##   [6] "sex"                                  
##   [7] "race_ethnicity"                       
##   [8] "reshist_addr1_pm252016aa.Baseline"    
##   [9] "abcd_site.Baseline"                   
##  [10] "interview_date.Baseline"              
##  [11] "rel_relationship.Baseline"            
##  [12] "rel_ingroup_order.Baseline"           
##  [13] "high.educ.Baseline"                   
##  [14] "interview_age.Baseline"               
##  [15] "demo_l_p_select_language___1.Baseline"
##  [16] "cbcl_select_language___1.Baseline"    
##  [17] "reshist_addr1_adi_perc.Baseline"      
##  [18] "reshist_addr1_adi_wsum.Baseline"      
##  [19] "overall.income.b.Baseline"            
##  [20] "overall.income.l.Baseline"            
##  [21] "overall.income.alltp.Baseline"        
##  [22] "prnt.empl.bl.Baseline"                
##  [23] "prnt.empl.l.Baseline"                 
##  [24] "prnt.empl.alltp.Baseline"             
##  [25] "neighb_phenx_avg_p.Baseline"          
##  [26] "neighb_phenx_sum_p.Baseline"          
##  [27] "reshist_addr1_popdensity.Baseline"    
##  [28] "reshist_addr1_proxrd.Baseline"        
##  [29] "married.Baseline"                     
##  [30] "married.or.livingtogether.Baseline"   
##  [31] "cbcl_scr_syn_internal_r.Baseline"     
##  [32] "cbcl_scr_syn_external_r.Baseline"     
##  [33] "cbcl_scr_syn_totprob_r.Baseline"      
##  [34] "cbcl_scr_syn_anxdep_r.Baseline"       
##  [35] "cbcl_scr_syn_withdep_r.Baseline"      
##  [36] "cbcl_scr_syn_attention_r.Baseline"    
##  [37] "cbcl_scr_syn_rulebreak_r.Baseline"    
##  [38] "cbcl_scr_syn_aggressive_r.Baseline"   
##  [39] "cbcl_scr_syn_internal_t.Baseline"     
##  [40] "cbcl_scr_syn_external_t.Baseline"     
##  [41] "cbcl_scr_syn_totprob_t.Baseline"      
##  [42] "cbcl_scr_syn_anxdep_t.Baseline"       
##  [43] "cbcl_scr_syn_withdep_t.Baseline"      
##  [44] "cbcl_scr_syn_attention_t.Baseline"    
##  [45] "cbcl_scr_syn_rulebreak_t.Baseline"    
##  [46] "cbcl_scr_syn_aggressive_t.Baseline"   
##  [47] "reshist_addr1_years.Baseline"         
##  [48] "income_midp.Baseline"                 
##  [49] "demo_comb_income_v2.Baseline"         
##  [50] "reshist_addr1_no2_2016_aavg.Baseline" 
##  [51] "reshist_addr1_o3_2016_annavg.Baseline"
##  [52] "reshist_addr1_pm252016aa.1.year"      
##  [53] "abcd_site.1.year"                     
##  [54] "interview_date.1.year"                
##  [55] "rel_relationship.1.year"              
##  [56] "rel_ingroup_order.1.year"             
##  [57] "high.educ.1.year"                     
##  [58] "interview_age.1.year"                 
##  [59] "demo_l_p_select_language___1.1.year"  
##  [60] "cbcl_select_language___1.1.year"      
##  [61] "reshist_addr1_adi_perc.1.year"        
##  [62] "reshist_addr1_adi_wsum.1.year"        
##  [63] "overall.income.b.1.year"              
##  [64] "overall.income.l.1.year"              
##  [65] "overall.income.alltp.1.year"          
##  [66] "prnt.empl.bl.1.year"                  
##  [67] "prnt.empl.l.1.year"                   
##  [68] "prnt.empl.alltp.1.year"               
##  [69] "neighb_phenx_avg_p.1.year"            
##  [70] "neighb_phenx_sum_p.1.year"            
##  [71] "reshist_addr1_popdensity.1.year"      
##  [72] "reshist_addr1_proxrd.1.year"          
##  [73] "married.1.year"                       
##  [74] "married.or.livingtogether.1.year"     
##  [75] "cbcl_scr_syn_internal_r.1.year"       
##  [76] "cbcl_scr_syn_external_r.1.year"       
##  [77] "cbcl_scr_syn_totprob_r.1.year"        
##  [78] "cbcl_scr_syn_anxdep_r.1.year"         
##  [79] "cbcl_scr_syn_withdep_r.1.year"        
##  [80] "cbcl_scr_syn_attention_r.1.year"      
##  [81] "cbcl_scr_syn_rulebreak_r.1.year"      
##  [82] "cbcl_scr_syn_aggressive_r.1.year"     
##  [83] "cbcl_scr_syn_internal_t.1.year"       
##  [84] "cbcl_scr_syn_external_t.1.year"       
##  [85] "cbcl_scr_syn_totprob_t.1.year"        
##  [86] "cbcl_scr_syn_anxdep_t.1.year"         
##  [87] "cbcl_scr_syn_withdep_t.1.year"        
##  [88] "cbcl_scr_syn_attention_t.1.year"      
##  [89] "cbcl_scr_syn_rulebreak_t.1.year"      
##  [90] "cbcl_scr_syn_aggressive_t.1.year"     
##  [91] "reshist_addr1_years.1.year"           
##  [92] "income_midp.1.year"                   
##  [93] "demo_comb_income_v2.1.year"           
##  [94] "reshist_addr1_no2_2016_aavg.1.year"   
##  [95] "reshist_addr1_o3_2016_annavg.1.year"  
##  [96] "reshist_addr1_pm252016aa.2.year"      
##  [97] "abcd_site.2.year"                     
##  [98] "interview_date.2.year"                
##  [99] "rel_relationship.2.year"              
## [100] "rel_ingroup_order.2.year"             
## [101] "high.educ.2.year"                     
## [102] "interview_age.2.year"                 
## [103] "demo_l_p_select_language___1.2.year"  
## [104] "cbcl_select_language___1.2.year"      
## [105] "reshist_addr1_adi_perc.2.year"        
## [106] "reshist_addr1_adi_wsum.2.year"        
## [107] "overall.income.b.2.year"              
## [108] "overall.income.l.2.year"              
## [109] "overall.income.alltp.2.year"          
## [110] "prnt.empl.bl.2.year"                  
## [111] "prnt.empl.l.2.year"                   
## [112] "prnt.empl.alltp.2.year"               
## [113] "neighb_phenx_avg_p.2.year"            
## [114] "neighb_phenx_sum_p.2.year"            
## [115] "reshist_addr1_popdensity.2.year"      
## [116] "reshist_addr1_proxrd.2.year"          
## [117] "married.2.year"                       
## [118] "married.or.livingtogether.2.year"     
## [119] "cbcl_scr_syn_internal_r.2.year"       
## [120] "cbcl_scr_syn_external_r.2.year"       
## [121] "cbcl_scr_syn_totprob_r.2.year"        
## [122] "cbcl_scr_syn_anxdep_r.2.year"         
## [123] "cbcl_scr_syn_withdep_r.2.year"        
## [124] "cbcl_scr_syn_attention_r.2.year"      
## [125] "cbcl_scr_syn_rulebreak_r.2.year"      
## [126] "cbcl_scr_syn_aggressive_r.2.year"     
## [127] "cbcl_scr_syn_internal_t.2.year"       
## [128] "cbcl_scr_syn_external_t.2.year"       
## [129] "cbcl_scr_syn_totprob_t.2.year"        
## [130] "cbcl_scr_syn_anxdep_t.2.year"         
## [131] "cbcl_scr_syn_withdep_t.2.year"        
## [132] "cbcl_scr_syn_attention_t.2.year"      
## [133] "cbcl_scr_syn_rulebreak_t.2.year"      
## [134] "cbcl_scr_syn_aggressive_t.2.year"     
## [135] "reshist_addr1_years.2.year"           
## [136] "income_midp.2.year"                   
## [137] "demo_comb_income_v2.2.year"           
## [138] "reshist_addr1_no2_2016_aavg.2.year"   
## [139] "reshist_addr1_o3_2016_annavg.2.year"  
## [140] "rel_relationship.1_year"
names(HEI_Aim2_Long_1KidPerFamily)
##  [1] "X"                               "subjectid"                      
##  [3] "rel_family_id"                   "abcd_site"                      
##  [5] "eventname"                       "rel_relationship"               
##  [7] "interview_date"                  "demo_l_p_select_language___1"   
##  [9] "cbcl_select_language___1"        "rel_group_id"                   
## [11] "rel_ingroup_order"               "rel_same_sex"                   
## [13] "reshist_addr1_pm252016aa"        "sex"                            
## [15] "interview_age"                   "race_ethnicity"                 
## [17] "high.educ"                       "reshist_addr1_adi_perc"         
## [19] "reshist_addr1_adi_wsum"          "overall.income.b"               
## [21] "overall.income.l"                "overall.income.alltp"           
## [23] "prnt.empl.bl"                    "prnt.empl.l"                    
## [25] "prnt.empl.alltp"                 "neighb_phenx_avg_p"             
## [27] "neighb_phenx_sum_p"              "reshist_addr1_popdensity"       
## [29] "reshist_addr1_proxrd"            "married"                        
## [31] "married.or.livingtogether"       "cbcl_scr_syn_internal_r"        
## [33] "cbcl_scr_syn_external_r"         "cbcl_scr_syn_totprob_r"         
## [35] "cbcl_scr_syn_anxdep_r"           "cbcl_scr_syn_withdep_r"         
## [37] "cbcl_scr_syn_attention_r"        "cbcl_scr_syn_rulebreak_r"       
## [39] "cbcl_scr_syn_aggressive_r"       "cbcl_scr_syn_internal_t"        
## [41] "cbcl_scr_syn_external_t"         "cbcl_scr_syn_totprob_t"         
## [43] "cbcl_scr_syn_anxdep_t"           "cbcl_scr_syn_withdep_t"         
## [45] "cbcl_scr_syn_attention_t"        "cbcl_scr_syn_rulebreak_t"       
## [47] "cbcl_scr_syn_aggressive_t"       "reshist_addr1_years"            
## [49] "income_midp"                     "demo_comb_income_v2"            
## [51] "reshist_addr1_no2_2016_aavg"     "reshist_addr1_o3_2016_annavg"   
## [53] "reshist_addr1_pm252016aa_bl"     "reshist_addr1_no2_2016_aavg_bl" 
## [55] "reshist_addr1_o3_2016_annavg_bl" "high.educ_bl"
# Note we are keeping all families but choosing one kid per family
length(unique(HEI_Aim2_Long$rel_family_id))
## [1] 9844
length(unique(HEI_Aim2_Long$subjectid)) # matches number of rows of wide data :)
## [1] 11866
length(unique(HEI_Aim2_Long_1KidPerFamily$rel_family_id))
## [1] 9844
length(unique(HEI_Aim2_Long_1KidPerFamily$subjectid))
## [1] 9844

Copy baseline variables to all timepoints for full df

#rename so can use later
names(HEI_Aim2_Long)[names(HEI_Aim2_Long) == 'prnt.empl.bl'] <- 'prnt.empl.b'

#create dataset for table and comparison
baseline_vars <- subset(HEI_Aim2_Long, HEI_Aim2_Long$eventname=="Baseline", select = c("subjectid", "sex", "race_ethnicity", "high.educ", "neighb_phenx_avg_p", "overall.income.b", "prnt.empl.b"))

#rename variables
names(baseline_vars)[names(baseline_vars) == 'sex'] <- 'sex.bl'
names(baseline_vars)[names(baseline_vars) == 'race_ethnicity'] <- 'race_ethnicity.bl'
names(baseline_vars)[names(baseline_vars) == 'high.educ'] <- 'high.educ.bl'
names(baseline_vars)[names(baseline_vars) == 'neighb_phenx_avg_p'] <- 'neighb_phenx_avg_p.bl'
names(baseline_vars)[names(baseline_vars) == 'overall.income.b'] <- 'overall.income.bl'
names(baseline_vars)[names(baseline_vars) == 'prnt.empl.b'] <- 'prnt.empl.bl'

#add to initial df
HEI_Aim2_Long_2 <- merge(HEI_Aim2_Long, baseline_vars, by="subjectid")

Descriptive Table before further Cleaning

#factor eventname
HEI_Aim2_Long_2$eventname <- as.factor(HEI_Aim2_Long_2$eventname)
HEI_Aim2_Long_2$eventname <- relevel(HEI_Aim2_Long_2$eventname , ref="Baseline")

#create smaller df
df_prior <- subset(HEI_Aim2_Long_2,select=c("subjectid","abcd_site","eventname","interview_age","reshist_addr1_pm252016aa_bl","prnt.empl.bl","overall.income.bl","sex.bl","race_ethnicity.bl","high.educ.bl","neighb_phenx_avg_p.bl","cbcl_scr_syn_internal_r","cbcl_scr_syn_external_r","cbcl_scr_syn_anxdep_r","cbcl_scr_syn_withdep_r","cbcl_scr_syn_attention_r","cbcl_scr_syn_rulebreak_r","cbcl_scr_syn_aggressive_r","cbcl_scr_syn_totprob_r"))
#create table
des_table_prior <- tableby(eventname ~ ., data = df_prior[ , -which(names(df_prior) %in% c("subjectid"))], total=F) 
summary(des_table_prior, title = "Descriptive Statistics by Eventname Before Cleaning")
## 
## 
## Table: Descriptive Statistics by Eventname Before Cleaning
## 
## |                                         | Baseline (N=11839) | 1-year (N=11200)  |  2-year (N=7334)  | p value|
## |:----------------------------------------|:------------------:|:-----------------:|:-----------------:|-------:|
## |**abcd_site**                            |                    |                   |                   | < 0.001|
## |&nbsp;&nbsp;&nbsp;site01                 |     406 (3.4%)     |    369 (3.3%)     |    210 (2.9%)     |        |
## |&nbsp;&nbsp;&nbsp;site02                 |     558 (4.7%)     |    548 (4.9%)     |    351 (4.8%)     |        |
## |&nbsp;&nbsp;&nbsp;site03                 |     631 (5.3%)     |    563 (5.0%)     |    372 (5.1%)     |        |
## |&nbsp;&nbsp;&nbsp;site04                 |     745 (6.3%)     |    727 (6.5%)     |    534 (7.3%)     |        |
## |&nbsp;&nbsp;&nbsp;site05                 |     378 (3.2%)     |    357 (3.2%)     |    234 (3.2%)     |        |
## |&nbsp;&nbsp;&nbsp;site06                 |     584 (4.9%)     |    568 (5.1%)     |    379 (5.2%)     |        |
## |&nbsp;&nbsp;&nbsp;site07                 |     339 (2.9%)     |    322 (2.9%)     |    116 (1.6%)     |        |
## |&nbsp;&nbsp;&nbsp;site08                 |     350 (3.0%)     |    339 (3.0%)     |    212 (2.9%)     |        |
## |&nbsp;&nbsp;&nbsp;site09                 |     433 (3.7%)     |    393 (3.5%)     |    227 (3.1%)     |        |
## |&nbsp;&nbsp;&nbsp;site10                 |     739 (6.2%)     |    708 (6.3%)     |    493 (6.7%)     |        |
## |&nbsp;&nbsp;&nbsp;site11                 |     450 (3.8%)     |    400 (3.6%)     |    197 (2.7%)     |        |
## |&nbsp;&nbsp;&nbsp;site12                 |     604 (5.1%)     |    550 (4.9%)     |    274 (3.7%)     |        |
## |&nbsp;&nbsp;&nbsp;site13                 |     728 (6.1%)     |    691 (6.2%)     |    443 (6.0%)     |        |
## |&nbsp;&nbsp;&nbsp;site14                 |     606 (5.1%)     |    583 (5.2%)     |    430 (5.9%)     |        |
## |&nbsp;&nbsp;&nbsp;site15                 |     458 (3.9%)     |    426 (3.8%)     |    266 (3.6%)     |        |
## |&nbsp;&nbsp;&nbsp;site16                 |    1011 (8.5%)     |    979 (8.7%)     |    640 (8.7%)     |        |
## |&nbsp;&nbsp;&nbsp;site17                 |     578 (4.9%)     |    562 (5.0%)     |    374 (5.1%)     |        |
## |&nbsp;&nbsp;&nbsp;site18                 |     384 (3.2%)     |    376 (3.4%)     |    223 (3.0%)     |        |
## |&nbsp;&nbsp;&nbsp;site19                 |     550 (4.6%)     |    521 (4.7%)     |    397 (5.4%)     |        |
## |&nbsp;&nbsp;&nbsp;site20                 |     707 (6.0%)     |    687 (6.1%)     |    528 (7.2%)     |        |
## |&nbsp;&nbsp;&nbsp;site21                 |     600 (5.1%)     |    531 (4.7%)     |    434 (5.9%)     |        |
## |**interview_age**                        |                    |                   |                   | < 0.001|
## |&nbsp;&nbsp;&nbsp;Mean (SD)              |  118.967 (7.495)   |  131.073 (7.714)  |  143.361 (7.747)  |        |
## |&nbsp;&nbsp;&nbsp;Range                  | 107.000 - 133.000  | 116.000 - 149.000 | 127.000 - 164.000 |        |
## |**reshist_addr1_pm252016aa_bl**          |                    |                   |                   |   0.745|
## |&nbsp;&nbsp;&nbsp;N-Miss                 |        651         |        587        |        224        |        |
## |&nbsp;&nbsp;&nbsp;Mean (SD)              |   7.663 (1.563)    |   7.648 (1.561)   |   7.650 (1.535)   |        |
## |&nbsp;&nbsp;&nbsp;Range                  |   1.722 - 15.902   |  1.722 - 15.902   |  1.722 - 15.902   |        |
## |**prnt.empl.bl**                         |                    |                   |                   |   0.098|
## |&nbsp;&nbsp;&nbsp;N-Miss                 |         56         |        47         |        22         |        |
## |&nbsp;&nbsp;&nbsp;Employed               |    8194 (69.5%)    |   7826 (70.2%)    |   5214 (71.3%)    |        |
## |&nbsp;&nbsp;&nbsp;Other                  |     855 (7.3%)     |    791 (7.1%)     |    474 (6.5%)     |        |
## |&nbsp;&nbsp;&nbsp;Stay at Home Parent    |    2065 (17.5%)    |   1941 (17.4%)    |   1262 (17.3%)    |        |
## |&nbsp;&nbsp;&nbsp;Unemployed             |     669 (5.7%)     |    595 (5.3%)     |    362 (5.0%)     |        |
## |**overall.income.bl**                    |                    |                   |                   |   0.001|
## |&nbsp;&nbsp;&nbsp;N-Miss                 |         2          |         1         |         0         |        |
## |&nbsp;&nbsp;&nbsp;[<50k]                 |    3215 (27.2%)    |   2930 (26.2%)    |   1833 (25.0%)    |        |
## |&nbsp;&nbsp;&nbsp;[>=100K]               |    4544 (38.4%)    |   4419 (39.5%)    |   2952 (40.3%)    |        |
## |&nbsp;&nbsp;&nbsp;[>=50K & <100K]        |    3065 (25.9%)    |   2937 (26.2%)    |   2000 (27.3%)    |        |
## |&nbsp;&nbsp;&nbsp;[Don't Know or Refuse] |    1013 (8.6%)     |    913 (8.2%)     |    549 (7.5%)     |        |
## |**sex.bl**                               |                    |                   |                   |   0.906|
## |&nbsp;&nbsp;&nbsp;Female                 |    5658 (47.8%)    |   5335 (47.6%)    |   3481 (47.5%)    |        |
## |&nbsp;&nbsp;&nbsp;Male                   |    6181 (52.2%)    |   5865 (52.4%)    |   3853 (52.5%)    |        |
## |**race_ethnicity.bl**                    |                    |                   |                   | < 0.001|
## |&nbsp;&nbsp;&nbsp;N-Miss                 |         2          |         2         |         0         |        |
## |&nbsp;&nbsp;&nbsp;Asian                  |     250 (2.1%)     |    239 (2.1%)     |    158 (2.2%)     |        |
## |&nbsp;&nbsp;&nbsp;Black                  |    1777 (15.0%)    |   1594 (14.2%)    |    874 (11.9%)    |        |
## |&nbsp;&nbsp;&nbsp;Hispanic               |    2405 (20.3%)    |   2220 (19.8%)    |   1411 (19.2%)    |        |
## |&nbsp;&nbsp;&nbsp;Other                  |    1243 (10.5%)    |   1171 (10.5%)    |    724 (9.9%)     |        |
## |&nbsp;&nbsp;&nbsp;White                  |    6162 (52.1%)    |   5974 (53.3%)    |   4167 (56.8%)    |        |
## |**high.educ.bl**                         |                    |                   |                   | < 0.001|
## |&nbsp;&nbsp;&nbsp;N-Miss                 |         14         |        12         |        10         |        |
## |&nbsp;&nbsp;&nbsp;< HS Diploma           |     592 (5.0%)     |    526 (4.7%)     |    306 (4.2%)     |        |
## |&nbsp;&nbsp;&nbsp;Bachelor               |    3006 (25.4%)    |   2889 (25.8%)    |   2002 (27.3%)    |        |
## |&nbsp;&nbsp;&nbsp;HS Diploma/GED         |    1129 (9.5%)     |    1007 (9.0%)    |    568 (7.8%)     |        |
## |&nbsp;&nbsp;&nbsp;Post Graduate Degree   |    4025 (34.0%)    |   3919 (35.0%)    |   2611 (35.6%)    |        |
## |&nbsp;&nbsp;&nbsp;Some College           |    3073 (26.0%)    |   2847 (25.4%)    |   1837 (25.1%)    |        |
## |**neighb_phenx_avg_p.bl**                |                    |                   |                   |   0.003|
## |&nbsp;&nbsp;&nbsp;N-Miss                 |         8          |         5         |         3         |        |
## |&nbsp;&nbsp;&nbsp;Mean (SD)              |   3.890 (0.975)    |   3.903 (0.969)   |   3.938 (0.942)   |        |
## |&nbsp;&nbsp;&nbsp;Range                  |   1.000 - 5.000    |   1.000 - 5.000   |   1.000 - 5.000   |        |
## |**cbcl_scr_syn_internal_r**              |                    |                   |                   |   0.100|
## |&nbsp;&nbsp;&nbsp;N-Miss                 |         8          |        18         |         5         |        |
## |&nbsp;&nbsp;&nbsp;Mean (SD)              |   5.043 (5.522)    |   5.108 (5.551)   |   4.930 (5.614)   |        |
## |&nbsp;&nbsp;&nbsp;Range                  |   0.000 - 51.000   |  0.000 - 48.000   |  0.000 - 50.000   |        |
## |**cbcl_scr_syn_external_r**              |                    |                   |                   | < 0.001|
## |&nbsp;&nbsp;&nbsp;N-Miss                 |         8          |        18         |         5         |        |
## |&nbsp;&nbsp;&nbsp;Mean (SD)              |   4.455 (5.867)    |   4.176 (5.656)   |   3.918 (5.479)   |        |
## |&nbsp;&nbsp;&nbsp;Range                  |   0.000 - 49.000   |  0.000 - 47.000   |  0.000 - 46.000   |        |
## |**cbcl_scr_syn_anxdep_r**                |                    |                   |                   | < 0.001|
## |&nbsp;&nbsp;&nbsp;N-Miss                 |         8          |        18         |         5         |        |
## |&nbsp;&nbsp;&nbsp;Mean (SD)              |   2.516 (3.062)    |   2.540 (3.072)   |   2.322 (2.971)   |        |
## |&nbsp;&nbsp;&nbsp;Range                  |   0.000 - 26.000   |  0.000 - 22.000   |  0.000 - 22.000   |        |
## |**cbcl_scr_syn_withdep_r**               |                    |                   |                   | < 0.001|
## |&nbsp;&nbsp;&nbsp;N-Miss                 |         8          |        18         |         5         |        |
## |&nbsp;&nbsp;&nbsp;Mean (SD)              |   1.034 (1.709)    |   1.116 (1.778)   |   1.201 (1.901)   |        |
## |&nbsp;&nbsp;&nbsp;Range                  |   0.000 - 15.000   |  0.000 - 14.000   |  0.000 - 16.000   |        |
## |**cbcl_scr_syn_attention_r**             |                    |                   |                   | < 0.001|
## |&nbsp;&nbsp;&nbsp;N-Miss                 |         8          |        18         |         5         |        |
## |&nbsp;&nbsp;&nbsp;Mean (SD)              |   2.977 (3.495)    |   2.858 (3.431)   |   2.692 (3.298)   |        |
## |&nbsp;&nbsp;&nbsp;Range                  |   0.000 - 20.000   |  0.000 - 19.000   |  0.000 - 19.000   |        |
## |**cbcl_scr_syn_rulebreak_r**             |                    |                   |                   | < 0.001|
## |&nbsp;&nbsp;&nbsp;N-Miss                 |         8          |        18         |         5         |        |
## |&nbsp;&nbsp;&nbsp;Mean (SD)              |   1.192 (1.861)    |   1.120 (1.822)   |   1.057 (1.833)   |        |
## |&nbsp;&nbsp;&nbsp;Range                  |   0.000 - 20.000   |  0.000 - 20.000   |  0.000 - 23.000   |        |
## |**cbcl_scr_syn_aggressive_r**            |                    |                   |                   | < 0.001|
## |&nbsp;&nbsp;&nbsp;N-Miss                 |         8          |        18         |         5         |        |
## |&nbsp;&nbsp;&nbsp;Mean (SD)              |   3.262 (4.355)    |   3.056 (4.185)   |   2.861 (3.990)   |        |
## |&nbsp;&nbsp;&nbsp;Range                  |   0.000 - 36.000   |  0.000 - 33.000   |  0.000 - 32.000   |        |
## |**cbcl_scr_syn_totprob_r**               |                    |                   |                   | < 0.001|
## |&nbsp;&nbsp;&nbsp;N-Miss                 |         8          |        18         |         5         |        |
## |&nbsp;&nbsp;&nbsp;Mean (SD)              |  18.178 (17.968)   |  17.520 (17.567)  |  16.388 (17.001)  |        |
## |&nbsp;&nbsp;&nbsp;Range                  |  0.000 - 139.000   |  0.000 - 128.000  |  0.000 - 161.000  |        |

Creating variables for modeling and tables

The following variables are time-invariant, will use baseline covariates since PM2.5 collected at baseline: - reshist_addr1_pm252016aa_bl which is the Baseline PM2.5. - reshist_addr1_no2_2016_aavg_bl which is the Baseline NO2. - sex.bl - race_ethnicity.bl - high.educ.bl - prnt.empl.bl - neighb_phenx_avg_p.bl - overall.income.bl

The following variables are time-varying: - all CBCL outcomes - interview_age

Copy baseline variables to all timepoints for 1KidPerFamily

#rename so can use later
names(HEI_Aim2_Long_1KidPerFamily)[names(HEI_Aim2_Long_1KidPerFamily) == 'prnt.empl.bl'] <- 'prnt.empl.b'

#create dataset for table and comparison
baseline_vars_1KidPerFamily <- subset(HEI_Aim2_Long_1KidPerFamily, HEI_Aim2_Long_1KidPerFamily$eventname=="Baseline", select = c("subjectid", "sex", "race_ethnicity", "high.educ", "neighb_phenx_avg_p", "overall.income.b"))

#rename variables
names(baseline_vars_1KidPerFamily)[names(baseline_vars_1KidPerFamily) == 'sex'] <- 'sex.bl'
names(baseline_vars_1KidPerFamily)[names(baseline_vars_1KidPerFamily) == 'race_ethnicity'] <- 'race_ethnicity.bl'
names(baseline_vars_1KidPerFamily)[names(baseline_vars_1KidPerFamily) == 'high.educ'] <- 'high.educ.bl'
names(baseline_vars_1KidPerFamily)[names(baseline_vars_1KidPerFamily) == 'neighb_phenx_avg_p'] <- 'neighb_phenx_avg_p.bl'
names(baseline_vars_1KidPerFamily)[names(baseline_vars_1KidPerFamily) == 'overall.income.b'] <- 'overall.income.bl'
names(baseline_vars_1KidPerFamily)[names(baseline_vars_1KidPerFamily) == 'prnt.empl.b'] <- 'prnt.empl.bl'

#add to initial df
HEI_Aim2_Long_1KidPerFamily_2 <- merge(HEI_Aim2_Long_1KidPerFamily, baseline_vars, by="subjectid")

Clean 1KidPerFamily

## Cleaning
#merge Asian into Other group b/c statistically Asian group is too small
tapply(HEI_Aim2_Long_1KidPerFamily_2$race_ethnicity.bl, 
       HEI_Aim2_Long_1KidPerFamily_2$eventname,table, useNA = "always")
## $`1-year`
## 
##    Asian    Black Hispanic    Other    White     <NA> 
##      217     1334     1932      964     4803        1 
## 
## $`2-year`
## 
##    Asian    Black Hispanic    Other    White     <NA> 
##      141      715     1232      597     3326        0 
## 
## $Baseline
## 
##    Asian    Black Hispanic    Other    White     <NA> 
##      228     1496     2101     1029     4963        1
HEI_Aim2_Long_1KidPerFamily_2$race_ethnicity.bl <- 
  ifelse(HEI_Aim2_Long_1KidPerFamily_2$race_ethnicity.bl=="Asian","Other",
         HEI_Aim2_Long_1KidPerFamily_2$race_ethnicity.bl)

tapply(HEI_Aim2_Long_1KidPerFamily_2$race_ethnicity.bl, 
       HEI_Aim2_Long_1KidPerFamily_2$eventname,table, useNA = "always")
## $`1-year`
## 
##    Black Hispanic    Other    White     <NA> 
##     1334     1932     1181     4803        1 
## 
## $`2-year`
## 
##    Black Hispanic    Other    White     <NA> 
##      715     1232      738     3326        0 
## 
## $Baseline
## 
##    Black Hispanic    Other    White     <NA> 
##     1496     2101     1257     4963        1
#reformat variables
HEI_Aim2_Long_1KidPerFamily_2$eventname <- 
  as.factor(HEI_Aim2_Long_1KidPerFamily_2$eventname)

HEI_Aim2_Long_1KidPerFamily_2$eventname <- 
  relevel(HEI_Aim2_Long_1KidPerFamily_2$eventname , ref="Baseline")

table(HEI_Aim2_Long_1KidPerFamily_2$eventname, useNA = "always")
## 
## Baseline   1-year   2-year     <NA> 
##     9818     9251     6011        0
HEI_Aim2_Long_1KidPerFamily_2$cbcl_scr_syn_internal_r <- as.numeric(HEI_Aim2_Long_1KidPerFamily_2$cbcl_scr_syn_internal_r)
HEI_Aim2_Long_1KidPerFamily_2$cbcl_scr_syn_external_r <- as.numeric(HEI_Aim2_Long_1KidPerFamily_2$cbcl_scr_syn_external_r)
HEI_Aim2_Long_1KidPerFamily_2$cbcl_scr_syn_anxdep_r <- as.numeric(HEI_Aim2_Long_1KidPerFamily_2$cbcl_scr_syn_anxdep_r)
HEI_Aim2_Long_1KidPerFamily_2$cbcl_scr_syn_withdep_r <- as.numeric(HEI_Aim2_Long_1KidPerFamily_2$cbcl_scr_syn_withdep_r)
HEI_Aim2_Long_1KidPerFamily_2$cbcl_scr_syn_attention_r <- as.numeric(HEI_Aim2_Long_1KidPerFamily_2$cbcl_scr_syn_attention_r)
HEI_Aim2_Long_1KidPerFamily_2$cbcl_scr_syn_rulebreak_r <- as.numeric(HEI_Aim2_Long_1KidPerFamily_2$cbcl_scr_syn_rulebreak_r)
HEI_Aim2_Long_1KidPerFamily_2$cbcl_scr_syn_aggressive_r <- as.numeric(HEI_Aim2_Long_1KidPerFamily_2$cbcl_scr_syn_aggressive_r)
HEI_Aim2_Long_1KidPerFamily_2$cbcl_scr_syn_totprob_r <- as.numeric(HEI_Aim2_Long_1KidPerFamily_2$cbcl_scr_syn_totprob_r)
HEI_Aim2_Long_1KidPerFamily_2$abcd_site <- as.factor(HEI_Aim2_Long_1KidPerFamily_2$abcd_site)
HEI_Aim2_Long_1KidPerFamily_2$subjectid <- as.factor(HEI_Aim2_Long_1KidPerFamily_2$subjectid)
HEI_Aim2_Long_1KidPerFamily_2$prnt.empl.bl <- factor(HEI_Aim2_Long_1KidPerFamily_2$prnt.empl.bl, levels = c("Employed", "Stay at Home Parent", "Unemployed", "Other"))
HEI_Aim2_Long_1KidPerFamily_2$overall.income.bl <- factor(HEI_Aim2_Long_1KidPerFamily_2$overall.income.bl, levels = c("[>=100K]", "[>=50K & <100K]", "[<50k]", "[Don't Know or Refuse]"))
HEI_Aim2_Long_1KidPerFamily_2$sex.bl <- factor(HEI_Aim2_Long_1KidPerFamily_2$sex.bl, levels = c("Male", "Female"))
HEI_Aim2_Long_1KidPerFamily_2$race_ethnicity.bl <- factor(HEI_Aim2_Long_1KidPerFamily_2$race_ethnicity.bl, levels = c("White", "Hispanic", "Black", "Other"))
HEI_Aim2_Long_1KidPerFamily_2$high.educ.bl <- factor(HEI_Aim2_Long_1KidPerFamily_2$high.educ.bl, levels = c("Post Graduate Degree", "Bachelor", "Some College", "HS Diploma/GED", "< HS Diploma"))

Create Final Dataset

#create smaller df
df <- subset(HEI_Aim2_Long_1KidPerFamily_2,select=c("subjectid","abcd_site","eventname","interview_age","reshist_addr1_pm252016aa_bl","reshist_addr1_no2_2016_aavg_bl","prnt.empl.bl","overall.income.bl","sex.bl","race_ethnicity.bl","high.educ.bl","neighb_phenx_avg_p.bl","cbcl_scr_syn_internal_r","cbcl_scr_syn_external_r","cbcl_scr_syn_anxdep_r","cbcl_scr_syn_withdep_r","cbcl_scr_syn_attention_r","cbcl_scr_syn_rulebreak_r","cbcl_scr_syn_aggressive_r","cbcl_scr_syn_totprob_r"))

#complete cases because needed for zinb
df_cc <- df[complete.cases(df),]

#percentage of subjects lost with complete.cases
lost_sub <- data.frame(table(df$eventname))
colnames(lost_sub) <- c("eventname","abcd")
interim <- data.frame(table(df_cc$eventname))[2]
lost_sub$sample <- interim$Freq
lost_sub$diff <- lost_sub$abcd - lost_sub$sample
lost_sub$percent <- lost_sub$diff/lost_sub$abcd

#center age at 9years-old (i.e., 108 months)
df_cc$interview_age.c9 <- df_cc$interview_age-108
#change to years
df_cc$interview_age.c9.y <- df_cc$interview_age.c9/12
#center pm2.5 to 5 (recommended by WHO)
df_cc$reshist_addr1_pm252016aa_bl.c5 <- df_cc$reshist_addr1_pm252016aa_bl-5
#center no2 to 5.33 (recommended by WHO)
df_cc$reshist_addr1_no2_2016_aavg_bl.c533 <- df_cc$reshist_addr1_no2_2016_aavg_bl-5.33

#center around mean
neighb_phenx_avg_p.bl.cm <- df_cc$neighb_phenx_avg_p.bl - mean(df_cc$neighb_phenx_avg_p.bl)

#create table
des_table <- tableby(eventname ~ ., data = df_cc[ , -which(names(df_cc) %in% c("subjectid"))], total=F) 
summary(des_table, title = "Descriptive Statistics by Eventname After Cleaning")
Descriptive Statistics by Eventname After Cleaning
Baseline (N=9271) 1-year (N=8759) 2-year (N=5827) p value
abcd_site < 0.001
   site01 323 (3.5%) 299 (3.4%) 184 (3.2%)
   site02 305 (3.3%) 298 (3.4%) 210 (3.6%)
   site03 556 (6.0%) 493 (5.6%) 330 (5.7%)
   site04 631 (6.8%) 615 (7.0%) 451 (7.7%)
   site05 322 (3.5%) 305 (3.5%) 203 (3.5%)
   site06 509 (5.5%) 495 (5.7%) 334 (5.7%)
   site07 290 (3.1%) 275 (3.1%) 102 (1.8%)
   site08 302 (3.3%) 289 (3.3%) 183 (3.1%)
   site09 404 (4.4%) 366 (4.2%) 214 (3.7%)
   site10 623 (6.7%) 592 (6.8%) 427 (7.3%)
   site11 382 (4.1%) 339 (3.9%) 166 (2.8%)
   site12 481 (5.2%) 438 (5.0%) 236 (4.1%)
   site13 617 (6.7%) 585 (6.7%) 387 (6.6%)
   site14 359 (3.9%) 344 (3.9%) 255 (4.4%)
   site15 398 (4.3%) 371 (4.2%) 232 (4.0%)
   site16 794 (8.6%) 769 (8.8%) 500 (8.6%)
   site17 509 (5.5%) 495 (5.7%) 336 (5.8%)
   site18 351 (3.8%) 344 (3.9%) 206 (3.5%)
   site19 216 (2.3%) 208 (2.4%) 185 (3.2%)
   site20 447 (4.8%) 433 (4.9%) 327 (5.6%)
   site21 452 (4.9%) 406 (4.6%) 359 (6.2%)
interview_age < 0.001
   Mean (SD) 118.856 (7.411) 130.924 (7.617) 143.081 (7.635)
   Range 107.000 - 133.000 117.000 - 149.000 127.000 - 164.000
reshist_addr1_pm252016aa_bl 0.771
   Mean (SD) 7.706 (1.571) 7.693 (1.571) 7.690 (1.552)
   Range 1.722 - 15.902 1.722 - 15.902 1.722 - 15.902
reshist_addr1_no2_2016_aavg_bl 0.972
   Mean (SD) 18.595 (5.571) 18.579 (5.567) 18.575 (5.573)
   Range 0.729 - 37.940 0.729 - 37.940 0.729 - 35.346
prnt.empl.bl 0.373
   Employed 6444 (69.5%) 6146 (70.2%) 4139 (71.0%)
   Stay at Home Parent 1612 (17.4%) 1516 (17.3%) 1002 (17.2%)
   Unemployed 539 (5.8%) 481 (5.5%) 299 (5.1%)
   Other 676 (7.3%) 616 (7.0%) 387 (6.6%)
overall.income.bl 0.018
   [>=100K] 3514 (37.9%) 3418 (39.0%) 2307 (39.6%)
   [>=50K & <100K] 2419 (26.1%) 2312 (26.4%) 1597 (27.4%)
   [<50k] 2564 (27.7%) 2335 (26.7%) 1494 (25.6%)
   [Don’t Know or Refuse] 774 (8.3%) 694 (7.9%) 429 (7.4%)
sex.bl 0.861
   Male 4858 (52.4%) 4605 (52.6%) 3080 (52.9%)
   Female 4413 (47.6%) 4154 (47.4%) 2747 (47.1%)
race_ethnicity.bl < 0.001
   White 4759 (51.3%) 4612 (52.7%) 3236 (55.5%)
   Hispanic 1958 (21.1%) 1800 (20.6%) 1198 (20.6%)
   Black 1363 (14.7%) 1221 (13.9%) 678 (11.6%)
   Other 1191 (12.8%) 1126 (12.9%) 715 (12.3%)
high.educ.bl 0.002
   Post Graduate Degree 3179 (34.3%) 3090 (35.3%) 2093 (35.9%)
   Bachelor 2310 (24.9%) 2217 (25.3%) 1551 (26.6%)
   Some College 2423 (26.1%) 2247 (25.7%) 1466 (25.2%)
   HS Diploma/GED 899 (9.7%) 800 (9.1%) 460 (7.9%)
   < HS Diploma 460 (5.0%) 405 (4.6%) 257 (4.4%)
neighb_phenx_avg_p.bl 0.034
   Mean (SD) 3.873 (0.976) 3.884 (0.971) 3.915 (0.948)
   Range 1.000 - 5.000 1.000 - 5.000 1.000 - 5.000
cbcl_scr_syn_internal_r 0.042
   Mean (SD) 5.154 (5.539) 5.281 (5.612) 5.047 (5.610)
   Range 0.000 - 51.000 0.000 - 48.000 0.000 - 50.000
cbcl_scr_syn_external_r < 0.001
   Mean (SD) 4.484 (5.798) 4.232 (5.622) 3.949 (5.368)
   Range 0.000 - 49.000 0.000 - 46.000 0.000 - 46.000
cbcl_scr_syn_anxdep_r < 0.001
   Mean (SD) 2.569 (3.060) 2.613 (3.091) 2.352 (2.941)
   Range 0.000 - 26.000 0.000 - 22.000 0.000 - 22.000
cbcl_scr_syn_withdep_r < 0.001
   Mean (SD) 1.045 (1.700) 1.151 (1.800) 1.235 (1.912)
   Range 0.000 - 14.000 0.000 - 14.000 0.000 - 16.000
cbcl_scr_syn_attention_r < 0.001
   Mean (SD) 3.042 (3.508) 2.941 (3.458) 2.782 (3.324)
   Range 0.000 - 19.000 0.000 - 19.000 0.000 - 19.000
cbcl_scr_syn_rulebreak_r < 0.001
   Mean (SD) 1.204 (1.844) 1.142 (1.823) 1.068 (1.829)
   Range 0.000 - 20.000 0.000 - 20.000 0.000 - 23.000
cbcl_scr_syn_aggressive_r < 0.001
   Mean (SD) 3.280 (4.305) 3.090 (4.154) 2.881 (3.894)
   Range 0.000 - 36.000 0.000 - 33.000 0.000 - 32.000
cbcl_scr_syn_totprob_r < 0.001
   Mean (SD) 18.519 (17.931) 17.986 (17.659) 16.755 (16.864)
   Range 0.000 - 139.000 0.000 - 128.000 0.000 - 161.000
interview_age.c9 < 0.001
   Mean (SD) 10.856 (7.411) 22.924 (7.617) 35.081 (7.635)
   Range -1.000 - 25.000 9.000 - 41.000 19.000 - 56.000
interview_age.c9.y < 0.001
   Mean (SD) 0.905 (0.618) 1.910 (0.635) 2.923 (0.636)
   Range -0.083 - 2.083 0.750 - 3.417 1.583 - 4.667
reshist_addr1_pm252016aa_bl.c5 0.771
   Mean (SD) 2.706 (1.571) 2.693 (1.571) 2.690 (1.552)
   Range -3.278 - 10.902 -3.278 - 10.902 -3.278 - 10.902
reshist_addr1_no2_2016_aavg_bl.c533 0.972
   Mean (SD) 13.265 (5.571) 13.249 (5.567) 13.245 (5.573)
   Range -4.601 - 32.610 -4.601 - 32.610 -4.601 - 30.016
Final_DF_Descriptives <- summary(des_table, title = "Descriptive Statistics by Eventname After Cleaning")
#write.csv(Final_DF_Descriptives, "Descriptives_Final_Dataset.csv")

Internalizing

CBCL + AP Longitudinal Models

Zero-Inflated (ZI) Negative Binomial (NB): glmm.zinb in NBZIMM package.

CBCL only needs one nested random intercept since we eliminated the family nesting by choosing one kid per family.

For the negative binomial portion of the model, we do not nest by subject since the ICC across subjects is very low.

internal_zinb_r <- glmm.zinb(cbcl_scr_syn_internal_r ~ reshist_addr1_pm252016aa_bl.c5*interview_age.c9.y + race_ethnicity.bl + high.educ.bl+ prnt.empl.bl  + neighb_phenx_avg_p.bl.cm + overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533, random = ~1|abcd_site/subjectid,
              zi_fixed = ~ reshist_addr1_pm252016aa_bl.c5*interview_age.c9.y + race_ethnicity.bl + high.educ.bl+ prnt.empl.bl  + neighb_phenx_avg_p.bl.cm + overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533, zi_random = ~1|abcd_site, data = df_cc)
## Computational iterations: 7 
## Computational time: 1.206 minutes
summary(internal_zinb_r)
## Linear mixed-effects model fit by maximum likelihood
##   Data: df_cc 
##   AIC BIC logLik
##    NA  NA     NA
## 
## Random effects:
##  Formula: ~1 | abcd_site
##         (Intercept)
## StdDev:   0.1084049
## 
##  Formula: ~1 | subjectid %in% abcd_site
##         (Intercept) Residual
## StdDev:   0.8512357 1.107149
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~invwt 
## Fixed effects:  cbcl_scr_syn_internal_r ~ reshist_addr1_pm252016aa_bl.c5 * interview_age.c9.y +      race_ethnicity.bl + high.educ.bl + prnt.empl.bl + neighb_phenx_avg_p.bl.cm +      overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533 
##                                                        Value  Std.Error    DF
## (Intercept)                                        1.3153073 0.05105041 14510
## reshist_addr1_pm252016aa_bl.c5                     0.0078568 0.01111178  9307
## interview_age.c9.y                                 0.0275201 0.00878765 14510
## race_ethnicity.blHispanic                         -0.0243546 0.03135380  9307
## race_ethnicity.blBlack                            -0.3586827 0.03532015  9307
## race_ethnicity.blOther                            -0.0507550 0.03170926  9307
## high.educ.blBachelor                               0.0198012 0.02650623  9307
## high.educ.blSome College                           0.0489022 0.03038442  9307
## high.educ.blHS Diploma/GED                        -0.1305187 0.04313049  9307
## high.educ.bl< HS Diploma                          -0.1089449 0.05555887  9307
## prnt.empl.blStay at Home Parent                    0.0306533 0.02695206  9307
## prnt.empl.blUnemployed                             0.1290158 0.04441220  9307
## prnt.empl.blOther                                  0.2001879 0.03882581  9307
## neighb_phenx_avg_p.bl.cm                          -0.1216138 0.01132191  9307
## overall.income.bl[>=50K & <100K]                   0.1087366 0.02683571  9307
## overall.income.bl[<50k]                            0.1703172 0.03382476  9307
## overall.income.bl[Don't Know or Refuse]            0.0708793 0.04256789  9307
## sex.blFemale                                       0.0500218 0.01969583  9307
## reshist_addr1_no2_2016_aavg_bl.c533               -0.0060889 0.00262873  9307
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.0092719 0.00281105 14510
##                                                      t-value p-value
## (Intercept)                                        25.764874  0.0000
## reshist_addr1_pm252016aa_bl.c5                      0.707073  0.4795
## interview_age.c9.y                                  3.131677  0.0017
## race_ethnicity.blHispanic                          -0.776768  0.4373
## race_ethnicity.blBlack                            -10.155185  0.0000
## race_ethnicity.blOther                             -1.600636  0.1095
## high.educ.blBachelor                                0.747041  0.4551
## high.educ.blSome College                            1.609448  0.1076
## high.educ.blHS Diploma/GED                         -3.026135  0.0025
## high.educ.bl< HS Diploma                           -1.960891  0.0499
## prnt.empl.blStay at Home Parent                     1.137326  0.2554
## prnt.empl.blUnemployed                              2.904963  0.0037
## prnt.empl.blOther                                   5.156053  0.0000
## neighb_phenx_avg_p.bl.cm                          -10.741460  0.0000
## overall.income.bl[>=50K & <100K]                    4.051937  0.0001
## overall.income.bl[<50k]                             5.035282  0.0000
## overall.income.bl[Don't Know or Refuse]             1.665088  0.0959
## sex.blFemale                                        2.539716  0.0111
## reshist_addr1_no2_2016_aavg_bl.c533                -2.316304  0.0206
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  -3.298374  0.0010
##  Correlation: 
##                                                   (Intr) rs_1_252016_.5 in_.9.
## reshist_addr1_pm252016aa_bl.c5                    -0.398                      
## interview_age.c9.y                                -0.304  0.375               
## race_ethnicity.blHispanic                         -0.027 -0.072          0.004
## race_ethnicity.blBlack                            -0.022 -0.025          0.007
## race_ethnicity.blOther                            -0.085 -0.020          0.004
## high.educ.blBachelor                              -0.185  0.000          0.000
## high.educ.blSome College                          -0.126 -0.014          0.003
## high.educ.blHS Diploma/GED                        -0.075 -0.007          0.005
## high.educ.bl< HS Diploma                          -0.028 -0.016         -0.002
## prnt.empl.blStay at Home Parent                   -0.084 -0.016          0.002
## prnt.empl.blUnemployed                            -0.026 -0.003          0.000
## prnt.empl.blOther                                 -0.039  0.003          0.007
## neighb_phenx_avg_p.bl.cm                          -0.182  0.052         -0.003
## overall.income.bl[>=50K & <100K]                  -0.124 -0.016          0.001
## overall.income.bl[<50k]                           -0.061 -0.027         -0.001
## overall.income.bl[Don't Know or Refuse]           -0.059 -0.027         -0.002
## sex.blFemale                                      -0.186 -0.003          0.004
## reshist_addr1_no2_2016_aavg_bl.c533               -0.519 -0.233          0.005
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.262 -0.432         -0.867
##                                                   rc_t.H rc_t.B rc_t.O hgh..B
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                             0.349                     
## race_ethnicity.blOther                             0.286  0.256              
## high.educ.blBachelor                              -0.019 -0.013 -0.001       
## high.educ.blSome College                          -0.111 -0.084 -0.024  0.455
## high.educ.blHS Diploma/GED                        -0.143 -0.142 -0.006  0.330
## high.educ.bl< HS Diploma                          -0.166 -0.071 -0.009  0.262
## prnt.empl.blStay at Home Parent                    0.044  0.091  0.018 -0.028
## prnt.empl.blUnemployed                             0.010 -0.040  0.010 -0.009
## prnt.empl.blOther                                  0.040  0.009 -0.012 -0.013
## neighb_phenx_avg_p.bl.cm                           0.029  0.137  0.040 -0.004
## overall.income.bl[>=50K & <100K]                  -0.091 -0.060 -0.014 -0.174
## overall.income.bl[<50k]                           -0.145 -0.181 -0.081 -0.159
## overall.income.bl[Don't Know or Refuse]           -0.097 -0.124 -0.061 -0.100
## sex.blFemale                                      -0.007 -0.017 -0.018  0.015
## reshist_addr1_no2_2016_aavg_bl.c533               -0.055 -0.082 -0.030  0.014
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.000 -0.002 -0.002 -0.001
##                                                   hg..SC h..HSD h..<HD p..aHP
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                         0.494                     
## high.educ.bl< HS Diploma                           0.406  0.372              
## prnt.empl.blStay at Home Parent                   -0.014 -0.050 -0.094       
## prnt.empl.blUnemployed                            -0.009 -0.068 -0.097  0.147
## prnt.empl.blOther                                 -0.033 -0.010 -0.019  0.158
## neighb_phenx_avg_p.bl.cm                           0.061  0.056  0.051  0.027
## overall.income.bl[>=50K & <100K]                  -0.277 -0.171 -0.113 -0.031
## overall.income.bl[<50k]                           -0.417 -0.364 -0.307 -0.054
## overall.income.bl[Don't Know or Refuse]           -0.250 -0.237 -0.218 -0.077
## sex.blFemale                                       0.023  0.015 -0.004 -0.006
## reshist_addr1_no2_2016_aavg_bl.c533                0.021  0.005 -0.018  0.006
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.001 -0.001  0.004  0.004
##                                                   prn..U prn..O n___.. o..[&<
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                  0.131                     
## neighb_phenx_avg_p.bl.cm                           0.021  0.004              
## overall.income.bl[>=50K & <100K]                  -0.015 -0.050  0.081       
## overall.income.bl[<50k]                           -0.101 -0.139  0.150  0.505
## overall.income.bl[Don't Know or Refuse]           -0.077 -0.098  0.083  0.359
## sex.blFemale                                       0.020  0.020  0.026 -0.006
## reshist_addr1_no2_2016_aavg_bl.c533               -0.010 -0.003  0.103 -0.010
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.002 -0.006  0.001 -0.002
##                                                   o..[<5 o..KoR sx.blF r_1_2_
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                                            
## neighb_phenx_avg_p.bl.cm                                                     
## overall.income.bl[>=50K & <100K]                                             
## overall.income.bl[<50k]                                                      
## overall.income.bl[Don't Know or Refuse]            0.482                     
## sex.blFemale                                      -0.007  0.008              
## reshist_addr1_no2_2016_aavg_bl.c533               -0.018 -0.004  0.000       
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.001  0.002 -0.001 -0.005
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -3.0452108 -0.7882604 -0.1957453  0.4336318  4.2772592 
## 
## Number of Observations: 23857
## Number of Groups: 
##                abcd_site subjectid %in% abcd_site 
##                       21                     9345
summary(internal_zinb_r$zi.fit)
## Linear mixed-effects model fit by maximum likelihood
##   Data: data 
##   AIC BIC logLik
##    NA  NA     NA
## 
## Random effects:
##  Formula: ~1 | abcd_site
##         (Intercept)  Residual
## StdDev:   0.3899559 0.6076061
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~invwt 
## Fixed effects:  zp ~ reshist_addr1_pm252016aa_bl.c5 * interview_age.c9.y + race_ethnicity.bl +      high.educ.bl + prnt.empl.bl + neighb_phenx_avg_p.bl.cm +      overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533 
##                                                       Value  Std.Error    DF
## (Intercept)                                       -3.926007 0.16280472 23817
## reshist_addr1_pm252016aa_bl.c5                    -0.028105 0.03615469 23817
## interview_age.c9.y                                -0.049121 0.04707073 23817
## race_ethnicity.blHispanic                          0.066927 0.07726332 23817
## race_ethnicity.blBlack                             0.893290 0.07379195 23817
## race_ethnicity.blOther                             0.385189 0.07534511 23817
## high.educ.blBachelor                               0.130870 0.06638952 23817
## high.educ.blSome College                           0.051135 0.07583844 23817
## high.educ.blHS Diploma/GED                         0.595885 0.09101122 23817
## high.educ.bl< HS Diploma                           0.813104 0.10627461 23817
## prnt.empl.blStay at Home Parent                   -0.051963 0.06520361 23817
## prnt.empl.blUnemployed                            -0.119281 0.09325067 23817
## prnt.empl.blOther                                  0.005704 0.08731933 23817
## neighb_phenx_avg_p.bl.cm                           0.254243 0.02675268 23817
## overall.income.bl[>=50K & <100K]                  -0.072396 0.06919594 23817
## overall.income.bl[<50k]                            0.012813 0.08024803 23817
## overall.income.bl[Don't Know or Refuse]            0.295554 0.08931692 23817
## sex.blFemale                                      -0.075385 0.04597174 23817
## reshist_addr1_no2_2016_aavg_bl.c533               -0.003520 0.00668834 23817
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.059262 0.01403646 23817
##                                                      t-value p-value
## (Intercept)                                       -24.114823  0.0000
## reshist_addr1_pm252016aa_bl.c5                     -0.777346  0.4370
## interview_age.c9.y                                 -1.043557  0.2967
## race_ethnicity.blHispanic                           0.866221  0.3864
## race_ethnicity.blBlack                             12.105525  0.0000
## race_ethnicity.blOther                              5.112332  0.0000
## high.educ.blBachelor                                1.971244  0.0487
## high.educ.blSome College                            0.674256  0.5002
## high.educ.blHS Diploma/GED                          6.547383  0.0000
## high.educ.bl< HS Diploma                            7.650974  0.0000
## prnt.empl.blStay at Home Parent                    -0.796939  0.4255
## prnt.empl.blUnemployed                             -1.279149  0.2009
## prnt.empl.blOther                                   0.065321  0.9479
## neighb_phenx_avg_p.bl.cm                            9.503460  0.0000
## overall.income.bl[>=50K & <100K]                   -1.046247  0.2955
## overall.income.bl[<50k]                             0.159666  0.8731
## overall.income.bl[Don't Know or Refuse]             3.309046  0.0009
## sex.blFemale                                       -1.639817  0.1011
## reshist_addr1_no2_2016_aavg_bl.c533                -0.526272  0.5987
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y   4.221971  0.0000
##  Correlation: 
##                                                   (Intr) rs_1_252016_.5 in_.9.
## reshist_addr1_pm252016aa_bl.c5                    -0.512                      
## interview_age.c9.y                                -0.532  0.628               
## race_ethnicity.blHispanic                         -0.031 -0.051          0.002
## race_ethnicity.blBlack                            -0.044 -0.014          0.021
## race_ethnicity.blOther                            -0.096  0.001          0.009
## high.educ.blBachelor                              -0.156  0.006         -0.004
## high.educ.blSome College                          -0.105 -0.005          0.007
## high.educ.blHS Diploma/GED                        -0.081  0.010          0.018
## high.educ.bl< HS Diploma                          -0.033 -0.010         -0.001
## prnt.empl.blStay at Home Parent                   -0.065 -0.019         -0.004
## prnt.empl.blUnemployed                            -0.027  0.007          0.009
## prnt.empl.blOther                                 -0.035  0.013          0.020
## neighb_phenx_avg_p.bl.cm                          -0.151  0.032         -0.002
## overall.income.bl[>=50K & <100K]                  -0.091 -0.009          0.002
## overall.income.bl[<50k]                           -0.045 -0.019         -0.007
## overall.income.bl[Don't Know or Refuse]           -0.050 -0.029          0.000
## sex.blFemale                                      -0.132 -0.004          0.006
## reshist_addr1_no2_2016_aavg_bl.c533               -0.413 -0.168         -0.003
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.469 -0.738         -0.875
##                                                   rc_t.H rc_t.B rc_t.O hgh..B
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                             0.464                     
## race_ethnicity.blOther                             0.353  0.342              
## high.educ.blBachelor                              -0.013 -0.006  0.007       
## high.educ.blSome College                          -0.114 -0.104 -0.009  0.479
## high.educ.blHS Diploma/GED                        -0.159 -0.160  0.002  0.410
## high.educ.bl< HS Diploma                          -0.186 -0.103 -0.003  0.357
## prnt.empl.blStay at Home Parent                    0.046  0.106  0.023 -0.023
## prnt.empl.blUnemployed                             0.017 -0.021  0.013 -0.018
## prnt.empl.blOther                                  0.057  0.012 -0.008 -0.017
## neighb_phenx_avg_p.bl.cm                           0.017  0.130  0.032  0.004
## overall.income.bl[>=50K & <100K]                  -0.105 -0.090 -0.024 -0.166
## overall.income.bl[<50k]                           -0.150 -0.206 -0.078 -0.158
## overall.income.bl[Don't Know or Refuse]           -0.117 -0.152 -0.068 -0.118
## sex.blFemale                                      -0.003 -0.026 -0.017  0.006
## reshist_addr1_no2_2016_aavg_bl.c533               -0.066 -0.103 -0.044  0.004
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.003 -0.007 -0.008  0.000
##                                                   hg..SC h..HSD h..<HD p..aHP
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                         0.588                     
## high.educ.bl< HS Diploma                           0.524  0.542              
## prnt.empl.blStay at Home Parent                   -0.013 -0.057 -0.125       
## prnt.empl.blUnemployed                            -0.005 -0.082 -0.121  0.176
## prnt.empl.blOther                                 -0.031 -0.022 -0.036  0.165
## neighb_phenx_avg_p.bl.cm                           0.049  0.050  0.053  0.033
## overall.income.bl[>=50K & <100K]                  -0.283 -0.207 -0.155 -0.025
## overall.income.bl[<50k]                           -0.409 -0.412 -0.386 -0.051
## overall.income.bl[Don't Know or Refuse]           -0.295 -0.308 -0.285 -0.094
## sex.blFemale                                       0.009  0.011 -0.014  0.012
## reshist_addr1_no2_2016_aavg_bl.c533                0.010 -0.010 -0.034  0.009
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.003 -0.006  0.007  0.016
##                                                   prn..U prn..O n___.. o..[&<
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                  0.149                     
## neighb_phenx_avg_p.bl.cm                           0.021 -0.010              
## overall.income.bl[>=50K & <100K]                  -0.014 -0.048  0.061       
## overall.income.bl[<50k]                           -0.081 -0.125  0.125  0.536
## overall.income.bl[Don't Know or Refuse]           -0.081 -0.109  0.071  0.438
## sex.blFemale                                       0.036  0.019  0.019 -0.006
## reshist_addr1_no2_2016_aavg_bl.c533               -0.011 -0.007  0.097 -0.019
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.006 -0.018  0.001 -0.003
##                                                   o..[<5 o..KoR sx.blF r_1_2_
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                                            
## neighb_phenx_avg_p.bl.cm                                                     
## overall.income.bl[>=50K & <100K]                                             
## overall.income.bl[<50k]                                                      
## overall.income.bl[Don't Know or Refuse]            0.603                     
## sex.blFemale                                      -0.004 -0.005              
## reshist_addr1_no2_2016_aavg_bl.c533               -0.031 -0.006  0.005       
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.006  0.006  0.002  0.004
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -0.8729333 -0.3076123 -0.2379597 -0.1768534 18.1306493 
## 
## Number of Observations: 23857
## Number of Groups: 21
anova(internal_zinb_r)
##                                                   numDF denDF   F-value p-value
## (Intercept)                                           1 14510 2669.5251  <.0001
## reshist_addr1_pm252016aa_bl.c5                        1  9307    0.0222  0.8815
## interview_age.c9.y                                    1 14510    0.2566  0.6125
## race_ethnicity.bl                                     3  9307   19.4934  <.0001
## high.educ.bl                                          4  9307   12.1081  <.0001
## prnt.empl.bl                                          3  9307   15.3185  <.0001
## neighb_phenx_avg_p.bl.cm                              1  9307  132.8621  <.0001
## overall.income.bl                                     3  9307    9.8506  <.0001
## sex.bl                                                1  9307    6.4381  0.0112
## reshist_addr1_no2_2016_aavg_bl.c533                   1  9307    5.4363  0.0197
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y     1 14510   10.8793  0.0010
VarCorr(internal_zinb_r)
##             Variance     StdDev   
## abcd_site = pdLogChol(1)          
## (Intercept) 0.01175163   0.1084049
## subjectid = pdLogChol(1)          
## (Intercept) 0.72460220   0.8512357
## Residual    1.22577990   1.1071494

Assumption checking for ZINB Models

  • Zero inflated negative binomial (zinb) regression already has overdispersion and excess zeros and this is accounted for in the zinb modeling chosen, “The data distribution combines the negative binomial distribution and the logit distribution”

  • Details on zinb can be found here: link

For Model Checking we will follow the following pdf: link This info is further detailed/published in books by Cameron and Trivedi (2013) and Hilbe (2014) and in Garay, Hashimoto, Ortega, and Lachos (2011).

They suggest using Pearson residuals.

#Check outlier/residuals with this df
internal_res <- df_cc
internal_res$level1_resid.raw <- residuals(internal_zinb_r)
internal_res$level1_resid.pearson <- residuals(internal_zinb_r, type="pearson")
#Add predicted values (Yhat)
internal_res$cbcl_scr_syn_internal_r_predicted <- predict(internal_zinb_r,internal_res,type="response")
#Incidence
internal_res$incidence <- estimate.probability(internal_res$cbcl_scr_syn_internal_r, method="empirical")

#Plotting histogram of residuals, but may be skewed since using ZINB, so make sure to check below plots
hist(internal_res$level1_resid.pearson)

Incidence vs. X’s Plots

“These plots show each of the independent variables plotted against the incidence as measured by Y (CBCL Outcome). They should be scanned for outliers and curvilinear patterns.”

#age
ggplot(internal_res,aes(incidence,interview_age)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

#pm2.5
ggplot(internal_res,aes(incidence,reshist_addr1_pm252016aa_bl)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

Residuals vs Y (CBCL Outcome) Plot

“This plot shows the residuals versus the dependent variable. It can be used to spot outliers.”

plot(internal_res$level1_resid.pearson, internal_res$cbcl_scr_syn_internal_r)

Residuals vs Yhat Plot

“This plot shows the residuals versus the predicted value (Yhat) of the dependent variable. It can show outliers.”

plot(internal_res$level1_resid.pearson, internal_res$cbcl_scr_syn_internal_r_predicted)

Residuals vs Row Plot

“This plot shows the residuals versus the row numbers. It is used to quickly spot rows that have large residuals.”

plot(as.numeric(rownames(internal_res)),internal_res$level1_resid.pearson)

Residuals vs X’s Plots

“These plots show the residuals plotted against the independent variables. They are used to spot outliers. They are also used to find curvilinear patterns that are not represented in the regression model.”

#age
ggplot(internal_res,aes(level1_resid.pearson,interview_age)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

#pm2.5
ggplot(internal_res,aes(level1_resid.pearson,reshist_addr1_pm252016aa_bl)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

For below models, view Internalizing above for notes.

Externalizing

CBCL + AP Longitudinal Models

external_zinb_r <- glmm.zinb(cbcl_scr_syn_external_r ~ reshist_addr1_pm252016aa_bl.c5*interview_age.c9.y + race_ethnicity.bl + high.educ.bl+ prnt.empl.bl  + neighb_phenx_avg_p.bl.cm + overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533, random = ~1|abcd_site/subjectid,
              zi_fixed = ~ reshist_addr1_pm252016aa_bl.c5*interview_age.c9.y + race_ethnicity.bl + high.educ.bl+ prnt.empl.bl  + neighb_phenx_avg_p.bl.cm + overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533, zi_random = ~1|abcd_site, data = df_cc)
## Computational iterations: 9 
## Computational time: 1.443 minutes
summary(external_zinb_r)
## Linear mixed-effects model fit by maximum likelihood
##   Data: df_cc 
##   AIC BIC logLik
##    NA  NA     NA
## 
## Random effects:
##  Formula: ~1 | abcd_site
##         (Intercept)
## StdDev:   0.1294082
## 
##  Formula: ~1 | subjectid %in% abcd_site
##         (Intercept) Residual
## StdDev:    1.099431 1.057932
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~invwt 
## Fixed effects:  cbcl_scr_syn_external_r ~ reshist_addr1_pm252016aa_bl.c5 * interview_age.c9.y +      race_ethnicity.bl + high.educ.bl + prnt.empl.bl + neighb_phenx_avg_p.bl.cm +      overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533 
##                                                        Value  Std.Error    DF
## (Intercept)                                        1.0211060 0.06320481 14510
## reshist_addr1_pm252016aa_bl.c5                    -0.0077650 0.01363091  9307
## interview_age.c9.y                                -0.0239486 0.00957918 14510
## race_ethnicity.blHispanic                         -0.0547048 0.04004575  9307
## race_ethnicity.blBlack                            -0.1035225 0.04439903  9307
## race_ethnicity.blOther                            -0.0375336 0.04074581  9307
## high.educ.blBachelor                               0.1079517 0.03414719  9307
## high.educ.blSome College                           0.1944569 0.03891004  9307
## high.educ.blHS Diploma/GED                         0.0686692 0.05456791  9307
## high.educ.bl< HS Diploma                           0.1027116 0.07027984  9307
## prnt.empl.blStay at Home Parent                    0.0120180 0.03457321  9307
## prnt.empl.blUnemployed                             0.1996353 0.05599056  9307
## prnt.empl.blOther                                  0.1979445 0.04940589  9307
## neighb_phenx_avg_p.bl.cm                          -0.1291003 0.01441675  9307
## overall.income.bl[>=50K & <100K]                   0.1279780 0.03450922  9307
## overall.income.bl[<50k]                            0.2649776 0.04315572  9307
## overall.income.bl[Don't Know or Refuse]            0.1667453 0.05412054  9307
## sex.blFemale                                      -0.2976364 0.02524457  9307
## reshist_addr1_no2_2016_aavg_bl.c533               -0.0049374 0.00332575  9307
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.0054209 0.00302668 14510
##                                                      t-value p-value
## (Intercept)                                        16.155511  0.0000
## reshist_addr1_pm252016aa_bl.c5                     -0.569658  0.5689
## interview_age.c9.y                                 -2.500071  0.0124
## race_ethnicity.blHispanic                          -1.366059  0.1720
## race_ethnicity.blBlack                             -2.331639  0.0197
## race_ethnicity.blOther                             -0.921165  0.3570
## high.educ.blBachelor                                3.161363  0.0016
## high.educ.blSome College                            4.997603  0.0000
## high.educ.blHS Diploma/GED                          1.258417  0.2083
## high.educ.bl< HS Diploma                            1.461466  0.1439
## prnt.empl.blStay at Home Parent                     0.347609  0.7281
## prnt.empl.blUnemployed                              3.565517  0.0004
## prnt.empl.blOther                                   4.006495  0.0001
## neighb_phenx_avg_p.bl.cm                           -8.954881  0.0000
## overall.income.bl[>=50K & <100K]                    3.708516  0.0002
## overall.income.bl[<50k]                             6.140035  0.0000
## overall.income.bl[Don't Know or Refuse]             3.080999  0.0021
## sex.blFemale                                      -11.790112  0.0000
## reshist_addr1_no2_2016_aavg_bl.c533                -1.484605  0.1377
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  -1.791028  0.0733
##  Correlation: 
##                                                   (Intr) rs_1_252016_.5 in_.9.
## reshist_addr1_pm252016aa_bl.c5                    -0.385                      
## interview_age.c9.y                                -0.262  0.325               
## race_ethnicity.blHispanic                         -0.024 -0.078          0.003
## race_ethnicity.blBlack                            -0.021 -0.030          0.006
## race_ethnicity.blOther                            -0.086 -0.025          0.003
## high.educ.blBachelor                              -0.194  0.001          0.000
## high.educ.blSome College                          -0.133 -0.015          0.002
## high.educ.blHS Diploma/GED                        -0.081 -0.008          0.005
## high.educ.bl< HS Diploma                          -0.032 -0.016         -0.001
## prnt.empl.blStay at Home Parent                   -0.085 -0.017          0.002
## prnt.empl.blUnemployed                            -0.026 -0.003          0.000
## prnt.empl.blOther                                 -0.039  0.002          0.007
## neighb_phenx_avg_p.bl.cm                          -0.186  0.056         -0.003
## overall.income.bl[>=50K & <100K]                  -0.131 -0.016          0.000
## overall.income.bl[<50k]                           -0.067 -0.028         -0.001
## overall.income.bl[Don't Know or Refuse]           -0.064 -0.029         -0.002
## sex.blFemale                                      -0.186 -0.004          0.003
## reshist_addr1_no2_2016_aavg_bl.c533               -0.534 -0.235          0.003
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.226 -0.373         -0.870
##                                                   rc_t.H rc_t.B rc_t.O hgh..B
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                             0.357                     
## race_ethnicity.blOther                             0.288  0.263              
## high.educ.blBachelor                              -0.022 -0.016 -0.002       
## high.educ.blSome College                          -0.111 -0.085 -0.025  0.461
## high.educ.blHS Diploma/GED                        -0.144 -0.147 -0.009  0.339
## high.educ.bl< HS Diploma                          -0.168 -0.077 -0.012  0.268
## prnt.empl.blStay at Home Parent                    0.043  0.092  0.017 -0.030
## prnt.empl.blUnemployed                             0.010 -0.040  0.010 -0.009
## prnt.empl.blOther                                  0.041  0.011 -0.011 -0.014
## neighb_phenx_avg_p.bl.cm                           0.030  0.136  0.042 -0.004
## overall.income.bl[>=50K & <100K]                  -0.088 -0.061 -0.011 -0.175
## overall.income.bl[<50k]                           -0.143 -0.182 -0.079 -0.160
## overall.income.bl[Don't Know or Refuse]           -0.096 -0.125 -0.056 -0.100
## sex.blFemale                                      -0.008 -0.019 -0.017  0.013
## reshist_addr1_no2_2016_aavg_bl.c533               -0.059 -0.083 -0.031  0.014
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.000 -0.001 -0.001 -0.001
##                                                   hg..SC h..HSD h..<HD p..aHP
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                         0.503                     
## high.educ.bl< HS Diploma                           0.413  0.381              
## prnt.empl.blStay at Home Parent                   -0.015 -0.050 -0.095       
## prnt.empl.blUnemployed                            -0.010 -0.069 -0.098  0.149
## prnt.empl.blOther                                 -0.033 -0.014 -0.020  0.159
## neighb_phenx_avg_p.bl.cm                           0.061  0.055  0.049  0.028
## overall.income.bl[>=50K & <100K]                  -0.276 -0.173 -0.115 -0.029
## overall.income.bl[<50k]                           -0.417 -0.367 -0.310 -0.052
## overall.income.bl[Don't Know or Refuse]           -0.253 -0.241 -0.220 -0.075
## sex.blFemale                                       0.022  0.014 -0.005 -0.006
## reshist_addr1_no2_2016_aavg_bl.c533                0.022  0.008 -0.016  0.005
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.001 -0.001  0.002  0.003
##                                                   prn..U prn..O n___.. o..[&<
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                  0.134                     
## neighb_phenx_avg_p.bl.cm                           0.023  0.003              
## overall.income.bl[>=50K & <100K]                  -0.014 -0.049  0.080       
## overall.income.bl[<50k]                           -0.101 -0.139  0.151  0.509
## overall.income.bl[Don't Know or Refuse]           -0.079 -0.099  0.083  0.364
## sex.blFemale                                       0.018  0.017  0.027 -0.006
## reshist_addr1_no2_2016_aavg_bl.c533               -0.011 -0.002  0.099 -0.009
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.002 -0.006  0.001 -0.001
##                                                   o..[<5 o..KoR sx.blF r_1_2_
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                                            
## neighb_phenx_avg_p.bl.cm                                                     
## overall.income.bl[>=50K & <100K]                                             
## overall.income.bl[<50k]                                                      
## overall.income.bl[Don't Know or Refuse]            0.490                     
## sex.blFemale                                      -0.007  0.007              
## reshist_addr1_no2_2016_aavg_bl.c533               -0.016 -0.003  0.000       
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.001  0.002  0.000 -0.003
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -3.2018245 -0.7290504 -0.2623209  0.3851928  4.4818057 
## 
## Number of Observations: 23857
## Number of Groups: 
##                abcd_site subjectid %in% abcd_site 
##                       21                     9345
summary(external_zinb_r$zi.fit)
## Linear mixed-effects model fit by maximum likelihood
##   Data: data 
##   AIC BIC logLik
##    NA  NA     NA
## 
## Random effects:
##  Formula: ~1 | abcd_site
##         (Intercept)  Residual
## StdDev:   0.2681476 0.5423461
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~invwt 
## Fixed effects:  zp ~ reshist_addr1_pm252016aa_bl.c5 * interview_age.c9.y + race_ethnicity.bl +      high.educ.bl + prnt.empl.bl + neighb_phenx_avg_p.bl.cm +      overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533 
##                                                       Value  Std.Error    DF
## (Intercept)                                       -4.121234 0.12997565 23817
## reshist_addr1_pm252016aa_bl.c5                     0.055019 0.03041678 23817
## interview_age.c9.y                                 0.200675 0.03769513 23817
## race_ethnicity.blHispanic                          0.203178 0.06360254 23817
## race_ethnicity.blBlack                             0.594394 0.06584425 23817
## race_ethnicity.blOther                             0.366721 0.06103961 23817
## high.educ.blBachelor                               0.106629 0.05358877 23817
## high.educ.blSome College                           0.143541 0.06233709 23817
## high.educ.blHS Diploma/GED                         0.414071 0.08155326 23817
## high.educ.bl< HS Diploma                           0.549831 0.09859802 23817
## prnt.empl.blStay at Home Parent                    0.018552 0.05396768 23817
## prnt.empl.blUnemployed                             0.022966 0.08288402 23817
## prnt.empl.blOther                                 -0.295705 0.08714322 23817
## neighb_phenx_avg_p.bl.cm                           0.203195 0.02329844 23817
## overall.income.bl[>=50K & <100K]                  -0.203062 0.05597617 23817
## overall.income.bl[<50k]                           -0.171169 0.06783270 23817
## overall.income.bl[Don't Know or Refuse]            0.165372 0.07685796 23817
## sex.blFemale                                       0.222933 0.03896640 23817
## reshist_addr1_no2_2016_aavg_bl.c533               -0.008428 0.00542719 23817
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.004830 0.01158174 23817
##                                                     t-value p-value
## (Intercept)                                       -31.70774  0.0000
## reshist_addr1_pm252016aa_bl.c5                      1.80884  0.0705
## interview_age.c9.y                                  5.32364  0.0000
## race_ethnicity.blHispanic                           3.19449  0.0014
## race_ethnicity.blBlack                              9.02727  0.0000
## race_ethnicity.blOther                              6.00791  0.0000
## high.educ.blBachelor                                1.98977  0.0466
## high.educ.blSome College                            2.30266  0.0213
## high.educ.blHS Diploma/GED                          5.07731  0.0000
## high.educ.bl< HS Diploma                            5.57649  0.0000
## prnt.empl.blStay at Home Parent                     0.34376  0.7310
## prnt.empl.blUnemployed                              0.27709  0.7817
## prnt.empl.blOther                                  -3.39333  0.0007
## neighb_phenx_avg_p.bl.cm                            8.72139  0.0000
## overall.income.bl[>=50K & <100K]                   -3.62766  0.0003
## overall.income.bl[<50k]                            -2.52340  0.0116
## overall.income.bl[Don't Know or Refuse]             2.15165  0.0314
## sex.blFemale                                        5.72117  0.0000
## reshist_addr1_no2_2016_aavg_bl.c533                -1.55300  0.1204
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y   0.41706  0.6766
##  Correlation: 
##                                                   (Intr) rs_1_252016_.5 in_.9.
## reshist_addr1_pm252016aa_bl.c5                    -0.543                      
## interview_age.c9.y                                -0.577  0.639               
## race_ethnicity.blHispanic                         -0.038 -0.046          0.007
## race_ethnicity.blBlack                            -0.043 -0.009          0.027
## race_ethnicity.blOther                            -0.096 -0.003          0.010
## high.educ.blBachelor                              -0.157  0.001         -0.006
## high.educ.blSome College                          -0.109 -0.009          0.002
## high.educ.blHS Diploma/GED                        -0.076  0.004          0.014
## high.educ.bl< HS Diploma                          -0.025 -0.026         -0.008
## prnt.empl.blStay at Home Parent                   -0.073 -0.015          0.001
## prnt.empl.blUnemployed                            -0.025  0.002          0.005
## prnt.empl.blOther                                 -0.030  0.012          0.016
## neighb_phenx_avg_p.bl.cm                          -0.167  0.036          0.000
## overall.income.bl[>=50K & <100K]                  -0.087 -0.006          0.001
## overall.income.bl[<50k]                           -0.037 -0.022         -0.007
## overall.income.bl[Don't Know or Refuse]           -0.043 -0.031         -0.003
## sex.blFemale                                      -0.165 -0.005          0.007
## reshist_addr1_no2_2016_aavg_bl.c533               -0.422 -0.163          0.005
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.493 -0.746         -0.859
##                                                   rc_t.H rc_t.B rc_t.O hgh..B
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                             0.407                     
## race_ethnicity.blOther                             0.334  0.305              
## high.educ.blBachelor                              -0.008 -0.005  0.012       
## high.educ.blSome College                          -0.116 -0.092 -0.009  0.459
## high.educ.blHS Diploma/GED                        -0.154 -0.151  0.002  0.362
## high.educ.bl< HS Diploma                          -0.172 -0.087  0.001  0.305
## prnt.empl.blStay at Home Parent                    0.046  0.104  0.021 -0.031
## prnt.empl.blUnemployed                             0.014 -0.031  0.013 -0.016
## prnt.empl.blOther                                  0.041  0.002 -0.013 -0.018
## neighb_phenx_avg_p.bl.cm                           0.022  0.128  0.031  0.001
## overall.income.bl[>=50K & <100K]                  -0.097 -0.080 -0.020 -0.159
## overall.income.bl[<50k]                           -0.141 -0.199 -0.079 -0.150
## overall.income.bl[Don't Know or Refuse]           -0.107 -0.140 -0.064 -0.108
## sex.blFemale                                      -0.003 -0.018 -0.012  0.012
## reshist_addr1_no2_2016_aavg_bl.c533               -0.064 -0.098 -0.039  0.011
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.001 -0.012 -0.008  0.003
##                                                   hg..SC h..HSD h..<HD p..aHP
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                         0.538                     
## high.educ.bl< HS Diploma                           0.469  0.464              
## prnt.empl.blStay at Home Parent                   -0.019 -0.058 -0.116       
## prnt.empl.blUnemployed                            -0.009 -0.078 -0.116  0.164
## prnt.empl.blOther                                 -0.027 -0.011 -0.027  0.140
## neighb_phenx_avg_p.bl.cm                           0.054  0.051  0.055  0.030
## overall.income.bl[>=50K & <100K]                  -0.285 -0.189 -0.135 -0.023
## overall.income.bl[<50k]                           -0.413 -0.396 -0.355 -0.048
## overall.income.bl[Don't Know or Refuse]           -0.284 -0.289 -0.270 -0.091
## sex.blFemale                                       0.017  0.012 -0.004  0.004
## reshist_addr1_no2_2016_aavg_bl.c533                0.018 -0.002 -0.021  0.011
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.001 -0.003  0.016  0.012
##                                                   prn..U prn..O n___.. o..[&<
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                  0.124                     
## neighb_phenx_avg_p.bl.cm                           0.026 -0.005              
## overall.income.bl[>=50K & <100K]                  -0.012 -0.041  0.073       
## overall.income.bl[<50k]                           -0.088 -0.117  0.133  0.490
## overall.income.bl[Don't Know or Refuse]           -0.083 -0.098  0.085  0.389
## sex.blFemale                                       0.031  0.013  0.023 -0.006
## reshist_addr1_no2_2016_aavg_bl.c533               -0.013 -0.006  0.110 -0.013
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.000 -0.014  0.000 -0.002
##                                                   o..[<5 o..KoR sx.blF r_1_2_
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                                            
## neighb_phenx_avg_p.bl.cm                                                     
## overall.income.bl[>=50K & <100K]                                             
## overall.income.bl[<50k]                                                      
## overall.income.bl[Don't Know or Refuse]            0.547                     
## sex.blFemale                                      -0.005  0.000              
## reshist_addr1_no2_2016_aavg_bl.c533               -0.022  0.000  0.007       
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.008  0.009  0.001 -0.006
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -0.8295843 -0.3553204 -0.2848921  0.2312446 17.3194845 
## 
## Number of Observations: 23857
## Number of Groups: 21
anova(external_zinb_r)
##                                                   numDF denDF  F-value p-value
## (Intercept)                                           1 14510 918.4594  <.0001
## reshist_addr1_pm252016aa_bl.c5                        1  9307   0.5341  0.4649
## interview_age.c9.y                                    1 14510  69.9272  <.0001
## race_ethnicity.bl                                     3  9307   5.9760  0.0005
## high.educ.bl                                          4  9307  31.8373  <.0001
## prnt.empl.bl                                          3  9307  15.2776  <.0001
## neighb_phenx_avg_p.bl.cm                              1  9307  91.7969  <.0001
## overall.income.bl                                     3  9307  12.2969  <.0001
## sex.bl                                                1  9307 139.0157  <.0001
## reshist_addr1_no2_2016_aavg_bl.c533                   1  9307   2.2187  0.1364
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y     1 14510   3.2078  0.0733
VarCorr(external_zinb_r)
##             Variance     StdDev   
## abcd_site = pdLogChol(1)          
## (Intercept) 0.01674648   0.1294082
## subjectid = pdLogChol(1)          
## (Intercept) 1.20874949   1.0994314
## Residual    1.11922050   1.0579322

Assumption checking for ZINB Models

#Check outlier/residuals with this df
external_res <- df_cc
external_res$level1_resid.raw <- residuals(external_zinb_r)
external_res$level1_resid.pearson <- residuals(external_zinb_r, type="pearson")
#Add predicted values (Yhat)
external_res$cbcl_scr_syn_external_r_predicted <- predict(external_zinb_r,external_res,type="response")
#Incidence
external_res$incidence <- estimate.probability(external_res$cbcl_scr_syn_external_r, method="empirical")

#Plotting histogram of residuals, but may be skewed since using ZINB, so make sure to check below plots
hist(external_res$level1_resid.pearson)

### Incidence vs. X’s Plots

#age
ggplot(external_res,aes(incidence,interview_age)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

#pm2.5
ggplot(external_res,aes(incidence,reshist_addr1_pm252016aa_bl)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

### Residuals vs Y (CBCL Outcome) Plot

plot(external_res$level1_resid.pearson, external_res$cbcl_scr_syn_external_r)

### Residuals vs Yhat Plot

plot(external_res$level1_resid.pearson, external_res$cbcl_scr_syn_external_r_predicted)

### Residuals vs Row Plot

plot(as.numeric(rownames(external_res)),external_res$level1_resid.pearson)

### Residuals vs X’s Plots

#age
ggplot(external_res,aes(level1_resid.pearson,interview_age)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

#pm2.5
ggplot(external_res,aes(level1_resid.pearson,reshist_addr1_pm252016aa_bl)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

Anxious/Depressed

CBCL + AP Longitudinal Models

anxdep_zinb_r <- glmm.zinb(cbcl_scr_syn_anxdep_r ~ reshist_addr1_pm252016aa_bl.c5*interview_age.c9.y + race_ethnicity.bl + high.educ.bl+ prnt.empl.bl  + neighb_phenx_avg_p.bl.cm + overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533, random = ~1|abcd_site/subjectid,
              zi_fixed = ~ reshist_addr1_pm252016aa_bl.c5*interview_age.c9.y + race_ethnicity.bl + high.educ.bl+ prnt.empl.bl  + neighb_phenx_avg_p.bl.cm + overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533, zi_random = ~1|abcd_site, data = df_cc)
## Computational iterations: 11 
## Computational time: 1.845 minutes
summary(anxdep_zinb_r)
## Linear mixed-effects model fit by maximum likelihood
##   Data: df_cc 
##   AIC BIC logLik
##    NA  NA     NA
## 
## Random effects:
##  Formula: ~1 | abcd_site
##         (Intercept)
## StdDev:   0.1232991
## 
##  Formula: ~1 | subjectid %in% abcd_site
##         (Intercept)  Residual
## StdDev:    0.971808 0.9387779
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~invwt 
## Fixed effects:  cbcl_scr_syn_anxdep_r ~ reshist_addr1_pm252016aa_bl.c5 * interview_age.c9.y +      race_ethnicity.bl + high.educ.bl + prnt.empl.bl + neighb_phenx_avg_p.bl.cm +      overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533 
##                                                        Value  Std.Error    DF
## (Intercept)                                        0.6762767 0.05866669 14510
## reshist_addr1_pm252016aa_bl.c5                    -0.0028472 0.01283374  9307
## interview_age.c9.y                                 0.0005011 0.01010981 14510
## race_ethnicity.blHispanic                         -0.0124020 0.03628362  9307
## race_ethnicity.blBlack                            -0.4364621 0.04131043  9307
## race_ethnicity.blOther                            -0.0965066 0.03679521  9307
## high.educ.blBachelor                              -0.0283915 0.03065143  9307
## high.educ.blSome College                          -0.0539359 0.03524092  9307
## high.educ.blHS Diploma/GED                        -0.2846316 0.05035520  9307
## high.educ.bl< HS Diploma                          -0.2716848 0.06496712  9307
## prnt.empl.blStay at Home Parent                    0.0397649 0.03125715  9307
## prnt.empl.blUnemployed                             0.1843156 0.05153048  9307
## prnt.empl.blOther                                  0.1504990 0.04525515  9307
## neighb_phenx_avg_p.bl.cm                          -0.1134722 0.01316139  9307
## overall.income.bl[>=50K & <100K]                   0.1123188 0.03104744  9307
## overall.income.bl[<50k]                            0.1616208 0.03927431  9307
## overall.income.bl[Don't Know or Refuse]            0.0351743 0.04956511  9307
## sex.blFemale                                       0.0551860 0.02285260  9307
## reshist_addr1_no2_2016_aavg_bl.c533               -0.0063207 0.00303574  9307
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.0093103 0.00327250 14510
##                                                      t-value p-value
## (Intercept)                                        11.527440  0.0000
## reshist_addr1_pm252016aa_bl.c5                     -0.221853  0.8244
## interview_age.c9.y                                  0.049564  0.9605
## race_ethnicity.blHispanic                          -0.341808  0.7325
## race_ethnicity.blBlack                            -10.565423  0.0000
## race_ethnicity.blOther                             -2.622802  0.0087
## high.educ.blBachelor                               -0.926271  0.3543
## high.educ.blSome College                           -1.530489  0.1259
## high.educ.blHS Diploma/GED                         -5.652478  0.0000
## high.educ.bl< HS Diploma                           -4.181881  0.0000
## prnt.empl.blStay at Home Parent                     1.272186  0.2033
## prnt.empl.blUnemployed                              3.576828  0.0003
## prnt.empl.blOther                                   3.325566  0.0009
## neighb_phenx_avg_p.bl.cm                           -8.621592  0.0000
## overall.income.bl[>=50K & <100K]                    3.617652  0.0003
## overall.income.bl[<50k]                             4.115177  0.0000
## overall.income.bl[Don't Know or Refuse]             0.709658  0.4779
## sex.blFemale                                        2.414869  0.0158
## reshist_addr1_no2_2016_aavg_bl.c533                -2.082111  0.0374
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  -2.845008  0.0044
##  Correlation: 
##                                                   (Intr) rs_1_252016_.5 in_.9.
## reshist_addr1_pm252016aa_bl.c5                    -0.397                      
## interview_age.c9.y                                -0.301  0.373               
## race_ethnicity.blHispanic                         -0.027 -0.073          0.004
## race_ethnicity.blBlack                            -0.023 -0.025          0.006
## race_ethnicity.blOther                            -0.085 -0.021          0.003
## high.educ.blBachelor                              -0.184 -0.001          0.000
## high.educ.blSome College                          -0.125 -0.015          0.003
## high.educ.blHS Diploma/GED                        -0.073 -0.009          0.005
## high.educ.bl< HS Diploma                          -0.027 -0.017         -0.002
## prnt.empl.blStay at Home Parent                   -0.084 -0.016          0.002
## prnt.empl.blUnemployed                            -0.026 -0.003          0.000
## prnt.empl.blOther                                 -0.039  0.002          0.007
## neighb_phenx_avg_p.bl.cm                          -0.184  0.054         -0.003
## overall.income.bl[>=50K & <100K]                  -0.126 -0.015          0.001
## overall.income.bl[<50k]                           -0.062 -0.026         -0.001
## overall.income.bl[Don't Know or Refuse]           -0.059 -0.027         -0.002
## sex.blFemale                                      -0.189 -0.002          0.003
## reshist_addr1_no2_2016_aavg_bl.c533               -0.521 -0.234          0.004
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.258 -0.430         -0.865
##                                                   rc_t.H rc_t.B rc_t.O hgh..B
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                             0.344                     
## race_ethnicity.blOther                             0.285  0.253              
## high.educ.blBachelor                              -0.018 -0.012  0.000       
## high.educ.blSome College                          -0.109 -0.082 -0.024  0.453
## high.educ.blHS Diploma/GED                        -0.141 -0.141 -0.006  0.327
## high.educ.bl< HS Diploma                          -0.166 -0.068 -0.009  0.258
## prnt.empl.blStay at Home Parent                    0.043  0.092  0.020 -0.031
## prnt.empl.blUnemployed                             0.010 -0.040  0.010 -0.009
## prnt.empl.blOther                                  0.040  0.010 -0.011 -0.013
## neighb_phenx_avg_p.bl.cm                           0.029  0.139  0.039 -0.005
## overall.income.bl[>=50K & <100K]                  -0.092 -0.059 -0.015 -0.175
## overall.income.bl[<50k]                           -0.146 -0.179 -0.081 -0.160
## overall.income.bl[Don't Know or Refuse]           -0.096 -0.120 -0.061 -0.100
## sex.blFemale                                      -0.008 -0.018 -0.018  0.015
## reshist_addr1_no2_2016_aavg_bl.c533               -0.054 -0.081 -0.029  0.014
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.000  0.000 -0.002 -0.001
##                                                   hg..SC h..HSD h..<HD p..aHP
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                         0.488                     
## high.educ.bl< HS Diploma                           0.401  0.367              
## prnt.empl.blStay at Home Parent                   -0.015 -0.053 -0.094       
## prnt.empl.blUnemployed                            -0.009 -0.069 -0.097  0.147
## prnt.empl.blOther                                 -0.033 -0.011 -0.020  0.157
## neighb_phenx_avg_p.bl.cm                           0.062  0.057  0.051  0.027
## overall.income.bl[>=50K & <100K]                  -0.277 -0.169 -0.111 -0.031
## overall.income.bl[<50k]                           -0.418 -0.362 -0.306 -0.052
## overall.income.bl[Don't Know or Refuse]           -0.249 -0.233 -0.215 -0.076
## sex.blFemale                                       0.023  0.015 -0.003 -0.006
## reshist_addr1_no2_2016_aavg_bl.c533                0.021  0.006 -0.018  0.006
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.001 -0.001  0.004  0.004
##                                                   prn..U prn..O n___.. o..[&<
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                  0.131                     
## neighb_phenx_avg_p.bl.cm                           0.022  0.004              
## overall.income.bl[>=50K & <100K]                  -0.014 -0.049  0.082       
## overall.income.bl[<50k]                           -0.102 -0.140  0.149  0.503
## overall.income.bl[Don't Know or Refuse]           -0.078 -0.097  0.083  0.355
## sex.blFemale                                       0.020  0.020  0.027 -0.006
## reshist_addr1_no2_2016_aavg_bl.c533               -0.011 -0.003  0.102 -0.009
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.003 -0.006  0.001 -0.001
##                                                   o..[<5 o..KoR sx.blF r_1_2_
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                                            
## neighb_phenx_avg_p.bl.cm                                                     
## overall.income.bl[>=50K & <100K]                                             
## overall.income.bl[<50k]                                                      
## overall.income.bl[Don't Know or Refuse]            0.477                     
## sex.blFemale                                      -0.007  0.008              
## reshist_addr1_no2_2016_aavg_bl.c533               -0.017 -0.004  0.001       
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.002  0.002 -0.001 -0.005
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -2.8149443 -0.7601946 -0.2212773  0.4359539  4.4148170 
## 
## Number of Observations: 23857
## Number of Groups: 
##                abcd_site subjectid %in% abcd_site 
##                       21                     9345
summary(anxdep_zinb_r$zi.fit)
## Linear mixed-effects model fit by maximum likelihood
##   Data: data 
##   AIC BIC logLik
##    NA  NA     NA
## 
## Random effects:
##  Formula: ~1 | abcd_site
##         (Intercept)  Residual
## StdDev:   0.4147199 0.4309516
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~invwt 
## Fixed effects:  zp ~ reshist_addr1_pm252016aa_bl.c5 * interview_age.c9.y + race_ethnicity.bl +      high.educ.bl + prnt.empl.bl + neighb_phenx_avg_p.bl.cm +      overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533 
##                                                       Value  Std.Error    DF
## (Intercept)                                       -4.909827 0.15368787 23817
## reshist_addr1_pm252016aa_bl.c5                    -0.099370 0.03191419 23817
## interview_age.c9.y                                 0.043321 0.03961885 23817
## race_ethnicity.blHispanic                          0.009406 0.06449590 23817
## race_ethnicity.blBlack                             1.027369 0.05900214 23817
## race_ethnicity.blOther                             0.315586 0.06450021 23817
## high.educ.blBachelor                               0.355437 0.05622283 23817
## high.educ.blSome College                           0.302606 0.06278469 23817
## high.educ.blHS Diploma/GED                         0.498365 0.07692219 23817
## high.educ.bl< HS Diploma                           0.896391 0.08538109 23817
## prnt.empl.blStay at Home Parent                    0.007080 0.05330213 23817
## prnt.empl.blUnemployed                            -0.086601 0.07195668 23817
## prnt.empl.blOther                                  0.013143 0.06849761 23817
## neighb_phenx_avg_p.bl.cm                           0.310656 0.02163439 23817
## overall.income.bl[>=50K & <100K]                  -0.206034 0.06018983 23817
## overall.income.bl[<50k]                            0.286803 0.06437230 23817
## overall.income.bl[Don't Know or Refuse]            0.339290 0.07406045 23817
## sex.blFemale                                      -0.326601 0.03809398 23817
## reshist_addr1_no2_2016_aavg_bl.c533                0.022451 0.00587493 23817
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.101816 0.01151053 23817
##                                                     t-value p-value
## (Intercept)                                       -31.94675  0.0000
## reshist_addr1_pm252016aa_bl.c5                     -3.11367  0.0018
## interview_age.c9.y                                  1.09344  0.2742
## race_ethnicity.blHispanic                           0.14584  0.8840
## race_ethnicity.blBlack                             17.41240  0.0000
## race_ethnicity.blOther                              4.89279  0.0000
## high.educ.blBachelor                                6.32194  0.0000
## high.educ.blSome College                            4.81973  0.0000
## high.educ.blHS Diploma/GED                          6.47882  0.0000
## high.educ.bl< HS Diploma                           10.49871  0.0000
## prnt.empl.blStay at Home Parent                     0.13282  0.8943
## prnt.empl.blUnemployed                             -1.20351  0.2288
## prnt.empl.blOther                                   0.19187  0.8478
## neighb_phenx_avg_p.bl.cm                           14.35935  0.0000
## overall.income.bl[>=50K & <100K]                   -3.42306  0.0006
## overall.income.bl[<50k]                             4.45538  0.0000
## overall.income.bl[Don't Know or Refuse]             4.58126  0.0000
## sex.blFemale                                       -8.57355  0.0000
## reshist_addr1_no2_2016_aavg_bl.c533                 3.82154  0.0001
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y   8.84544  0.0000
##  Correlation: 
##                                                   (Intr) rs_1_252016_.5 in_.9.
## reshist_addr1_pm252016aa_bl.c5                    -0.487                      
## interview_age.c9.y                                -0.520  0.654               
## race_ethnicity.blHispanic                         -0.029 -0.043         -0.001
## race_ethnicity.blBlack                            -0.040 -0.011          0.021
## race_ethnicity.blOther                            -0.083  0.006          0.006
## high.educ.blBachelor                              -0.162  0.004         -0.003
## high.educ.blSome College                          -0.113 -0.007          0.009
## high.educ.blHS Diploma/GED                        -0.090  0.011          0.019
## high.educ.bl< HS Diploma                          -0.049 -0.009          0.001
## prnt.empl.blStay at Home Parent                   -0.064 -0.015          0.000
## prnt.empl.blUnemployed                            -0.029  0.010          0.014
## prnt.empl.blOther                                 -0.032  0.014          0.019
## neighb_phenx_avg_p.bl.cm                          -0.130  0.022         -0.004
## overall.income.bl[>=50K & <100K]                  -0.081 -0.004          0.002
## overall.income.bl[<50k]                           -0.047 -0.017         -0.005
## overall.income.bl[Don't Know or Refuse]           -0.051 -0.025          0.003
## sex.blFemale                                      -0.103 -0.001          0.007
## reshist_addr1_no2_2016_aavg_bl.c533               -0.393 -0.169         -0.006
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.464 -0.771         -0.882
##                                                   rc_t.H rc_t.B rc_t.O hgh..B
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                             0.493                     
## race_ethnicity.blOther                             0.359  0.367              
## high.educ.blBachelor                              -0.017 -0.003  0.006       
## high.educ.blSome College                          -0.107 -0.099 -0.011  0.542
## high.educ.blHS Diploma/GED                        -0.143 -0.148  0.001  0.452
## high.educ.bl< HS Diploma                          -0.174 -0.104 -0.010  0.411
## prnt.empl.blStay at Home Parent                    0.051  0.108  0.032 -0.017
## prnt.empl.blUnemployed                             0.014 -0.013  0.018 -0.020
## prnt.empl.blOther                                  0.060  0.011 -0.001 -0.014
## neighb_phenx_avg_p.bl.cm                           0.014  0.139  0.032  0.007
## overall.income.bl[>=50K & <100K]                  -0.103 -0.096 -0.024 -0.159
## overall.income.bl[<50k]                           -0.161 -0.212 -0.081 -0.165
## overall.income.bl[Don't Know or Refuse]           -0.119 -0.151 -0.066 -0.120
## sex.blFemale                                      -0.004 -0.036 -0.021  0.009
## reshist_addr1_no2_2016_aavg_bl.c533               -0.067 -0.115 -0.053  0.006
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.007  0.000 -0.005  0.002
##                                                   hg..SC h..HSD h..<HD p..aHP
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                         0.622                     
## high.educ.bl< HS Diploma                           0.575  0.557              
## prnt.empl.blStay at Home Parent                   -0.010 -0.053 -0.121       
## prnt.empl.blUnemployed                            -0.004 -0.086 -0.120  0.184
## prnt.empl.blOther                                 -0.029 -0.025 -0.029  0.171
## neighb_phenx_avg_p.bl.cm                           0.049  0.044  0.049  0.040
## overall.income.bl[>=50K & <100K]                  -0.273 -0.194 -0.156 -0.022
## overall.income.bl[<50k]                           -0.420 -0.390 -0.375 -0.051
## overall.income.bl[Don't Know or Refuse]           -0.292 -0.283 -0.268 -0.087
## sex.blFemale                                       0.010  0.014 -0.013  0.017
## reshist_addr1_no2_2016_aavg_bl.c533                0.008 -0.009 -0.033  0.008
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.002 -0.008  0.009  0.015
##                                                   prn..U prn..O n___.. o..[&<
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                  0.160                     
## neighb_phenx_avg_p.bl.cm                           0.032 -0.014              
## overall.income.bl[>=50K & <100K]                  -0.010 -0.039  0.053       
## overall.income.bl[<50k]                           -0.082 -0.127  0.127  0.550
## overall.income.bl[Don't Know or Refuse]           -0.082 -0.112  0.069  0.436
## sex.blFemale                                       0.038  0.020  0.016  0.004
## reshist_addr1_no2_2016_aavg_bl.c533               -0.005 -0.006  0.083 -0.023
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.011 -0.019  0.010 -0.004
##                                                   o..[<5 o..KoR sx.blF r_1_2_
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                                            
## neighb_phenx_avg_p.bl.cm                                                     
## overall.income.bl[>=50K & <100K]                                             
## overall.income.bl[<50k]                                                      
## overall.income.bl[Don't Know or Refuse]            0.616                     
## sex.blFemale                                      -0.002 -0.003              
## reshist_addr1_no2_2016_aavg_bl.c533               -0.033 -0.007  0.004       
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.007  0.005 -0.003  0.009
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -1.6591629 -0.3334675 -0.2302656  0.2378951 37.2688755 
## 
## Number of Observations: 23857
## Number of Groups: 21
anova(anxdep_zinb_r)
##                                                   numDF denDF  F-value p-value
## (Intercept)                                           1 14510 337.5860  <.0001
## reshist_addr1_pm252016aa_bl.c5                        1  9307   3.3983  0.0653
## interview_age.c9.y                                    1 14510  22.3540  <.0001
## race_ethnicity.bl                                     3  9307  32.5402  <.0001
## high.educ.bl                                          4  9307   5.8412  0.0001
## prnt.empl.bl                                          3  9307  10.1838  <.0001
## neighb_phenx_avg_p.bl.cm                              1  9307  85.4505  <.0001
## overall.income.bl                                     3  9307   7.6765  <.0001
## sex.bl                                                1  9307   5.8272  0.0158
## reshist_addr1_no2_2016_aavg_bl.c533                   1  9307   4.3902  0.0362
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y     1 14510   8.0941  0.0044
# r2_efron(anxdep_zinb_r)
# anxdep_zinb_r$logLik
# 
# r2_efron(anxdep_nb_r$lme)
# anxdep_nb_r$logLik

Assumption checking for ZINB Models

#Check outlier/residuals with this df
anxdep_res <- df_cc
anxdep_res$level1_resid.raw <- residuals(anxdep_zinb_r)
anxdep_res$level1_resid.pearson <- residuals(anxdep_zinb_r, type="pearson")
#Add predicted values (Yhat)
anxdep_res$cbcl_scr_syn_anxdep_r_predicted <- predict(anxdep_zinb_r,anxdep_res,type="response")
#Incidence
anxdep_res$incidence <- estimate.probability(anxdep_res$cbcl_scr_syn_anxdep_r, method="empirical")

#Plotting histogram of residuals, but may be skewed since using ZINB, so make sure to check below plots
hist(anxdep_res$level1_resid.pearson)

### Incidence vs. X’s Plots

#age
ggplot(anxdep_res,aes(incidence,interview_age)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

#pm2.5
ggplot(anxdep_res,aes(incidence,reshist_addr1_pm252016aa_bl)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

### Residuals vs Y (CBCL Outcome) Plot

plot(anxdep_res$level1_resid.pearson, anxdep_res$cbcl_scr_syn_anxdep_r)

### Residuals vs Yhat Plot

plot(anxdep_res$level1_resid.pearson, anxdep_res$cbcl_scr_syn_anxdep_r_predicted)

### Residuals vs Row Plot

plot(as.numeric(rownames(anxdep_res)),anxdep_res$level1_resid.pearson)

### Residuals vs X’s Plots

#age
ggplot(anxdep_res,aes(level1_resid.pearson,interview_age)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

#pm2.5
ggplot(anxdep_res,aes(level1_resid.pearson,reshist_addr1_pm252016aa_bl)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

Withdrawn/Depressed

CBCL + AP Longitudinal Models

withdep_zinb_r <- glmm.zinb(cbcl_scr_syn_withdep_r ~ reshist_addr1_pm252016aa_bl.c5*interview_age.c9.y + race_ethnicity.bl + high.educ.bl+ prnt.empl.bl  + neighb_phenx_avg_p.bl.cm + overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533, random = ~1|abcd_site/subjectid,
              zi_fixed = ~ reshist_addr1_pm252016aa_bl.c5*interview_age.c9.y + race_ethnicity.bl + high.educ.bl+ prnt.empl.bl  + neighb_phenx_avg_p.bl.cm + overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533, zi_random = ~1|abcd_site, data = df_cc)
## Computational iterations: 15 
## Computational time: 2.478 minutes
summary(withdep_zinb_r)
## Linear mixed-effects model fit by maximum likelihood
##   Data: df_cc 
##   AIC BIC logLik
##    NA  NA     NA
## 
## Random effects:
##  Formula: ~1 | abcd_site
##         (Intercept)
## StdDev:   0.1165029
## 
##  Formula: ~1 | subjectid %in% abcd_site
##         (Intercept) Residual
## StdDev:    1.206047 0.806354
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~invwt 
## Fixed effects:  cbcl_scr_syn_withdep_r ~ reshist_addr1_pm252016aa_bl.c5 * interview_age.c9.y +      race_ethnicity.bl + high.educ.bl + prnt.empl.bl + neighb_phenx_avg_p.bl.cm +      overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533 
##                                                        Value  Std.Error    DF
## (Intercept)                                       -0.8001088 0.07060800 14510
## reshist_addr1_pm252016aa_bl.c5                     0.0086739 0.01569056  9307
## interview_age.c9.y                                 0.1231426 0.01308412 14510
## race_ethnicity.blHispanic                         -0.0081732 0.04636963  9307
## race_ethnicity.blBlack                            -0.3070256 0.05232687  9307
## race_ethnicity.blOther                             0.0204093 0.04718607  9307
## high.educ.blBachelor                               0.0768304 0.04009043  9307
## high.educ.blSome College                           0.1946432 0.04547991  9307
## high.educ.blHS Diploma/GED                         0.0918529 0.06366810  9307
## high.educ.bl< HS Diploma                           0.1319487 0.08124908  9307
## prnt.empl.blStay at Home Parent                    0.0783155 0.04012623  9307
## prnt.empl.blUnemployed                             0.2383777 0.06480874  9307
## prnt.empl.blOther                                  0.2801519 0.05706675  9307
## neighb_phenx_avg_p.bl.cm                          -0.1449913 0.01673625  9307
## overall.income.bl[>=50K & <100K]                   0.1611700 0.04040551  9307
## overall.income.bl[<50k]                            0.2823832 0.05029365  9307
## overall.income.bl[Don't Know or Refuse]            0.2445229 0.06313333  9307
## sex.blFemale                                      -0.0721862 0.02947994  9307
## reshist_addr1_no2_2016_aavg_bl.c533               -0.0036946 0.00369410  9307
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.0105938 0.00412280 14510
##                                                      t-value p-value
## (Intercept)                                       -11.331702  0.0000
## reshist_addr1_pm252016aa_bl.c5                      0.552809  0.5804
## interview_age.c9.y                                  9.411606  0.0000
## race_ethnicity.blHispanic                          -0.176261  0.8601
## race_ethnicity.blBlack                             -5.867456  0.0000
## race_ethnicity.blOther                              0.432529  0.6654
## high.educ.blBachelor                                1.916428  0.0553
## high.educ.blSome College                            4.279761  0.0000
## high.educ.blHS Diploma/GED                          1.442683  0.1491
## high.educ.bl< HS Diploma                            1.624002  0.1044
## prnt.empl.blStay at Home Parent                     1.951728  0.0510
## prnt.empl.blUnemployed                              3.678172  0.0002
## prnt.empl.blOther                                   4.909196  0.0000
## neighb_phenx_avg_p.bl.cm                           -8.663308  0.0000
## overall.income.bl[>=50K & <100K]                    3.988812  0.0001
## overall.income.bl[<50k]                             5.614688  0.0000
## overall.income.bl[Don't Know or Refuse]             3.873119  0.0001
## sex.blFemale                                       -2.448655  0.0144
## reshist_addr1_no2_2016_aavg_bl.c533                -1.000139  0.3173
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  -2.569567  0.0102
##  Correlation: 
##                                                   (Intr) rs_1_252016_.5 in_.9.
## reshist_addr1_pm252016aa_bl.c5                    -0.418                      
## interview_age.c9.y                                -0.337  0.404               
## race_ethnicity.blHispanic                         -0.022 -0.090          0.004
## race_ethnicity.blBlack                            -0.024 -0.040          0.007
## race_ethnicity.blOther                            -0.092 -0.034          0.003
## high.educ.blBachelor                              -0.203 -0.004         -0.001
## high.educ.blSome College                          -0.141 -0.020          0.003
## high.educ.blHS Diploma/GED                        -0.084 -0.012          0.006
## high.educ.bl< HS Diploma                          -0.036 -0.021         -0.001
## prnt.empl.blStay at Home Parent                   -0.089 -0.019          0.003
## prnt.empl.blUnemployed                            -0.028 -0.005          0.001
## prnt.empl.blOther                                 -0.043  0.002          0.008
## neighb_phenx_avg_p.bl.cm                          -0.193  0.063         -0.003
## overall.income.bl[>=50K & <100K]                  -0.144 -0.014          0.002
## overall.income.bl[<50k]                           -0.077 -0.028         -0.001
## overall.income.bl[Don't Know or Refuse]           -0.071 -0.028         -0.002
## sex.blFemale                                      -0.198 -0.005          0.003
## reshist_addr1_no2_2016_aavg_bl.c533               -0.547 -0.207          0.003
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.290 -0.465         -0.868
##                                                   rc_t.H rc_t.B rc_t.O hgh..B
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                             0.363                     
## race_ethnicity.blOther                             0.291  0.262              
## high.educ.blBachelor                              -0.019 -0.013 -0.001       
## high.educ.blSome College                          -0.113 -0.089 -0.024  0.464
## high.educ.blHS Diploma/GED                        -0.145 -0.149 -0.008  0.341
## high.educ.bl< HS Diploma                          -0.174 -0.076 -0.009  0.273
## prnt.empl.blStay at Home Parent                    0.041  0.091  0.017 -0.027
## prnt.empl.blUnemployed                             0.007 -0.042  0.009 -0.006
## prnt.empl.blOther                                  0.042  0.011 -0.009 -0.011
## neighb_phenx_avg_p.bl.cm                           0.030  0.140  0.041 -0.006
## overall.income.bl[>=50K & <100K]                  -0.088 -0.058 -0.008 -0.174
## overall.income.bl[<50k]                           -0.145 -0.180 -0.078 -0.162
## overall.income.bl[Don't Know or Refuse]           -0.103 -0.126 -0.062 -0.102
## sex.blFemale                                      -0.008 -0.015 -0.018  0.017
## reshist_addr1_no2_2016_aavg_bl.c533               -0.055 -0.075 -0.024  0.015
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.000 -0.002 -0.001  0.000
##                                                   hg..SC h..HSD h..<HD p..aHP
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                         0.508                     
## high.educ.bl< HS Diploma                           0.421  0.388              
## prnt.empl.blStay at Home Parent                   -0.013 -0.050 -0.094       
## prnt.empl.blUnemployed                            -0.007 -0.068 -0.098  0.152
## prnt.empl.blOther                                 -0.032 -0.008 -0.017  0.162
## neighb_phenx_avg_p.bl.cm                           0.061  0.057  0.051  0.027
## overall.income.bl[>=50K & <100K]                  -0.276 -0.172 -0.116 -0.030
## overall.income.bl[<50k]                           -0.418 -0.369 -0.312 -0.053
## overall.income.bl[Don't Know or Refuse]           -0.255 -0.243 -0.226 -0.077
## sex.blFemale                                       0.024  0.015 -0.002 -0.005
## reshist_addr1_no2_2016_aavg_bl.c533                0.024  0.007 -0.013  0.005
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.001 -0.001  0.002  0.004
##                                                   prn..U prn..O n___.. o..[&<
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                  0.135                     
## neighb_phenx_avg_p.bl.cm                           0.018  0.005              
## overall.income.bl[>=50K & <100K]                  -0.017 -0.051  0.078       
## overall.income.bl[<50k]                           -0.099 -0.142  0.150  0.513
## overall.income.bl[Don't Know or Refuse]           -0.080 -0.099  0.085  0.369
## sex.blFemale                                       0.018  0.020  0.029 -0.008
## reshist_addr1_no2_2016_aavg_bl.c533               -0.010 -0.003  0.100 -0.007
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.002 -0.007  0.000 -0.002
##                                                   o..[<5 o..KoR sx.blF r_1_2_
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                                            
## neighb_phenx_avg_p.bl.cm                                                     
## overall.income.bl[>=50K & <100K]                                             
## overall.income.bl[<50k]                                                      
## overall.income.bl[Don't Know or Refuse]            0.497                     
## sex.blFemale                                      -0.006  0.007              
## reshist_addr1_no2_2016_aavg_bl.c533               -0.010  0.000 -0.001       
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.001  0.002  0.000 -0.003
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -2.7577250 -0.6298805 -0.5045120  0.3858890  4.6880642 
## 
## Number of Observations: 23857
## Number of Groups: 
##                abcd_site subjectid %in% abcd_site 
##                       21                     9345
summary(withdep_zinb_r$zi.fit)
## Linear mixed-effects model fit by maximum likelihood
##   Data: data 
##   AIC BIC logLik
##    NA  NA     NA
## 
## Random effects:
##  Formula: ~1 | abcd_site
##         (Intercept)  Residual
## StdDev:   0.5499231 0.2649912
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~invwt 
## Fixed effects:  zp ~ reshist_addr1_pm252016aa_bl.c5 * interview_age.c9.y + race_ethnicity.bl +      high.educ.bl + prnt.empl.bl + neighb_phenx_avg_p.bl.cm +      overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533 
##                                                       Value  Std.Error    DF
## (Intercept)                                       -3.687353 0.13413415 23817
## reshist_addr1_pm252016aa_bl.c5                     0.090518 0.01630247 23817
## interview_age.c9.y                                -0.161258 0.02046086 23817
## race_ethnicity.blHispanic                          0.152709 0.03327454 23817
## race_ethnicity.blBlack                             0.559740 0.03597775 23817
## race_ethnicity.blOther                             0.016267 0.03527193 23817
## high.educ.blBachelor                               0.273600 0.02666866 23817
## high.educ.blSome College                           0.298743 0.03246994 23817
## high.educ.blHS Diploma/GED                         0.205809 0.04895767 23817
## high.educ.bl< HS Diploma                           0.642096 0.05816722 23817
## prnt.empl.blStay at Home Parent                   -0.620143 0.03530450 23817
## prnt.empl.blUnemployed                            -0.151483 0.05013473 23817
## prnt.empl.blOther                                 -0.042648 0.04319550 23817
## neighb_phenx_avg_p.bl.cm                           0.465801 0.01405981 23817
## overall.income.bl[>=50K & <100K]                  -0.488245 0.02932071 23817
## overall.income.bl[<50k]                           -0.821929 0.03885078 23817
## overall.income.bl[Don't Know or Refuse]            0.322457 0.03746702 23817
## sex.blFemale                                       0.205124 0.02085760 23817
## reshist_addr1_no2_2016_aavg_bl.c533                0.003134 0.00310367 23817
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.014003 0.00680183 23817
##                                                     t-value p-value
## (Intercept)                                       -27.49004  0.0000
## reshist_addr1_pm252016aa_bl.c5                      5.55242  0.0000
## interview_age.c9.y                                 -7.88131  0.0000
## race_ethnicity.blHispanic                           4.58937  0.0000
## race_ethnicity.blBlack                             15.55794  0.0000
## race_ethnicity.blOther                              0.46119  0.6447
## high.educ.blBachelor                               10.25924  0.0000
## high.educ.blSome College                            9.20062  0.0000
## high.educ.blHS Diploma/GED                          4.20382  0.0000
## high.educ.bl< HS Diploma                           11.03880  0.0000
## prnt.empl.blStay at Home Parent                   -17.56557  0.0000
## prnt.empl.blUnemployed                             -3.02152  0.0025
## prnt.empl.blOther                                  -0.98734  0.3235
## neighb_phenx_avg_p.bl.cm                           33.12994  0.0000
## overall.income.bl[>=50K & <100K]                  -16.65189  0.0000
## overall.income.bl[<50k]                           -21.15606  0.0000
## overall.income.bl[Don't Know or Refuse]             8.60643  0.0000
## sex.blFemale                                        9.83448  0.0000
## reshist_addr1_no2_2016_aavg_bl.c533                 1.00992  0.3125
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  -2.05870  0.0395
##  Correlation: 
##                                                   (Intr) rs_1_252016_.5 in_.9.
## reshist_addr1_pm252016aa_bl.c5                    -0.259                      
## interview_age.c9.y                                -0.247  0.566               
## race_ethnicity.blHispanic                         -0.019 -0.030          0.008
## race_ethnicity.blBlack                            -0.012  0.005          0.028
## race_ethnicity.blOther                            -0.045  0.017          0.020
## high.educ.blBachelor                              -0.079  0.006         -0.012
## high.educ.blSome College                          -0.054 -0.001         -0.005
## high.educ.blHS Diploma/GED                        -0.033  0.018          0.016
## high.educ.bl< HS Diploma                          -0.005 -0.027         -0.008
## prnt.empl.blStay at Home Parent                   -0.028 -0.006         -0.001
## prnt.empl.blUnemployed                            -0.010 -0.003         -0.004
## prnt.empl.blOther                                 -0.016  0.023          0.016
## neighb_phenx_avg_p.bl.cm                          -0.101  0.035          0.007
## overall.income.bl[>=50K & <100K]                  -0.030 -0.010          0.007
## overall.income.bl[<50k]                           -0.010 -0.013         -0.003
## overall.income.bl[Don't Know or Refuse]           -0.013 -0.030         -0.001
## sex.blFemale                                      -0.080 -0.014         -0.004
## reshist_addr1_no2_2016_aavg_bl.c533               -0.223 -0.204         -0.001
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.210 -0.660         -0.855
##                                                   rc_t.H rc_t.B rc_t.O hgh..B
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                             0.352                     
## race_ethnicity.blOther                             0.278  0.230              
## high.educ.blBachelor                              -0.007 -0.002  0.017       
## high.educ.blSome College                          -0.115 -0.108  0.007  0.439
## high.educ.blHS Diploma/GED                        -0.134 -0.141  0.005  0.300
## high.educ.bl< HS Diploma                          -0.157 -0.073  0.007  0.258
## prnt.empl.blStay at Home Parent                    0.038  0.083  0.018 -0.036
## prnt.empl.blUnemployed                             0.013 -0.026  0.017 -0.024
## prnt.empl.blOther                                  0.036 -0.013 -0.022 -0.027
## neighb_phenx_avg_p.bl.cm                           0.014  0.099  0.030 -0.004
## overall.income.bl[>=50K & <100K]                  -0.102 -0.086 -0.023 -0.140
## overall.income.bl[<50k]                           -0.122 -0.191 -0.061 -0.114
## overall.income.bl[Don't Know or Refuse]           -0.110 -0.168 -0.066 -0.094
## sex.blFemale                                      -0.004 -0.016 -0.009  0.008
## reshist_addr1_no2_2016_aavg_bl.c533               -0.064 -0.116 -0.044  0.001
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.001 -0.014 -0.017  0.004
##                                                   hg..SC h..HSD h..<HD p..aHP
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                         0.440                     
## high.educ.bl< HS Diploma                           0.397  0.356              
## prnt.empl.blStay at Home Parent                   -0.020 -0.046 -0.104       
## prnt.empl.blUnemployed                            -0.016 -0.065 -0.128  0.112
## prnt.empl.blOther                                 -0.042 -0.024 -0.045  0.113
## neighb_phenx_avg_p.bl.cm                           0.047  0.032  0.040  0.009
## overall.income.bl[>=50K & <100K]                  -0.273 -0.161 -0.107 -0.018
## overall.income.bl[<50k]                           -0.362 -0.324 -0.318 -0.028
## overall.income.bl[Don't Know or Refuse]           -0.279 -0.271 -0.271 -0.076
## sex.blFemale                                       0.018  0.007 -0.015  0.002
## reshist_addr1_no2_2016_aavg_bl.c533                0.008 -0.015 -0.034  0.005
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.003 -0.010  0.015  0.011
##                                                   prn..U prn..O n___.. o..[&<
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                  0.115                     
## neighb_phenx_avg_p.bl.cm                           0.029 -0.018              
## overall.income.bl[>=50K & <100K]                  -0.010 -0.049  0.066       
## overall.income.bl[<50k]                           -0.076 -0.114  0.109  0.405
## overall.income.bl[Don't Know or Refuse]           -0.079 -0.106  0.069  0.366
## sex.blFemale                                       0.030  0.010  0.028 -0.018
## reshist_addr1_no2_2016_aavg_bl.c533               -0.010 -0.009  0.112 -0.021
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.008 -0.014 -0.012 -0.005
##                                                   o..[<5 o..KoR sx.blF r_1_2_
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                                            
## neighb_phenx_avg_p.bl.cm                                                     
## overall.income.bl[>=50K & <100K]                                             
## overall.income.bl[<50k]                                                      
## overall.income.bl[Don't Know or Refuse]            0.491                     
## sex.blFemale                                      -0.015  0.001              
## reshist_addr1_no2_2016_aavg_bl.c533               -0.033 -0.013  0.008       
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.002  0.001  0.009  0.000
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -2.5666723 -0.4949188  0.1670057  0.2648371 41.7956765 
## 
## Number of Observations: 23857
## Number of Groups: 21
anova(withdep_zinb_r)
##                                                   numDF denDF   F-value p-value
## (Intercept)                                           1 14510 228.43817  <.0001
## reshist_addr1_pm252016aa_bl.c5                        1  9307   2.70550  0.1000
## interview_age.c9.y                                    1 14510 202.78340  <.0001
## race_ethnicity.bl                                     3  9307   7.49358  0.0001
## high.educ.bl                                          4  9307  28.00592  <.0001
## prnt.empl.bl                                          3  9307  17.99566  <.0001
## neighb_phenx_avg_p.bl.cm                              1  9307  90.53312  <.0001
## overall.income.bl                                     3  9307  11.37439  <.0001
## sex.bl                                                1  9307   5.99550  0.0144
## reshist_addr1_no2_2016_aavg_bl.c533                   1  9307   1.01734  0.3132
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y     1 14510   6.60268  0.0102

Assumption checking for ZINB Models

#Check outlier/residuals with this df
withdep_res <- df_cc
withdep_res$level1_resid.raw <- residuals(withdep_zinb_r)
withdep_res$level1_resid.pearson <- residuals(withdep_zinb_r, type="pearson")
#Add predicted values (Yhat)
withdep_res$cbcl_scr_syn_withdep_r_predicted <- predict(withdep_zinb_r,withdep_res,type="response")
#Incidence
withdep_res$incidence <- estimate.probability(withdep_res$cbcl_scr_syn_withdep_r, method="empirical")

#Plotting histogram of residuals, but may be skewed since using ZINB, so make sure to check below plots
hist(withdep_res$level1_resid.pearson)

### Incidence vs. X’s Plots

#age
ggplot(withdep_res,aes(incidence,interview_age)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
## : pseudoinverse used at 0
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
## : neighborhood radius 7.4176e-05
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
## : reciprocal condition number 1.0709e-14
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
## : There are other near singularities as well. 1.3755e-09
## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
## else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at 0
## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
## else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
## 7.4176e-05
## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
## else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
## number 1.0709e-14
## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
## else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : There are other near
## singularities as well. 1.3755e-09

#pm2.5
ggplot(withdep_res,aes(incidence,reshist_addr1_pm252016aa_bl)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
## : pseudoinverse used at 0
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
## : neighborhood radius 7.4176e-05
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
## : reciprocal condition number 1.0709e-14
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
## : There are other near singularities as well. 1.3755e-09
## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
## else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at 0
## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
## else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
## 7.4176e-05
## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
## else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
## number 1.0709e-14
## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
## else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : There are other near
## singularities as well. 1.3755e-09

### Residuals vs Y (CBCL Outcome) Plot

plot(withdep_res$level1_resid.pearson, withdep_res$cbcl_scr_syn_withdep_r)

### Residuals vs Yhat Plot

plot(withdep_res$level1_resid.pearson, withdep_res$cbcl_scr_syn_withdep_r_predicted)

### Residuals vs Row Plot

plot(as.numeric(rownames(withdep_res)),withdep_res$level1_resid.pearson)

### Residuals vs X’s Plots

#age
ggplot(withdep_res,aes(level1_resid.pearson,interview_age)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

#pm2.5
ggplot(withdep_res,aes(level1_resid.pearson,reshist_addr1_pm252016aa_bl)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

Attention

CBCL + AP Longitudinal Models

attention_zinb_r <- glmm.zinb(cbcl_scr_syn_attention_r ~ reshist_addr1_pm252016aa_bl.c5*interview_age.c9.y + race_ethnicity.bl + high.educ.bl+ prnt.empl.bl  + neighb_phenx_avg_p.bl.cm + overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533, random = ~1|abcd_site/subjectid,
              zi_fixed = ~ reshist_addr1_pm252016aa_bl.c5*interview_age.c9.y + race_ethnicity.bl + high.educ.bl+ prnt.empl.bl  + neighb_phenx_avg_p.bl.cm + overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533, zi_random = ~1|abcd_site, data = df_cc)
## Computational iterations: 14 
## Computational time: 2.495 minutes
summary(attention_zinb_r)
## Linear mixed-effects model fit by maximum likelihood
##   Data: df_cc 
##   AIC BIC logLik
##    NA  NA     NA
## 
## Random effects:
##  Formula: ~1 | abcd_site
##         (Intercept)
## StdDev:   0.1347084
## 
##  Formula: ~1 | subjectid %in% abcd_site
##         (Intercept)  Residual
## StdDev:    1.139804 0.9078062
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~invwt 
## Fixed effects:  cbcl_scr_syn_attention_r ~ reshist_addr1_pm252016aa_bl.c5 * interview_age.c9.y +      race_ethnicity.bl + high.educ.bl + prnt.empl.bl + neighb_phenx_avg_p.bl.cm +      overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533 
##                                                        Value  Std.Error    DF
## (Intercept)                                        0.7494678 0.06541076 14510
## reshist_addr1_pm252016aa_bl.c5                    -0.0047347 0.01409363  9307
## interview_age.c9.y                                -0.0283232 0.00948437 14510
## race_ethnicity.blHispanic                         -0.0494567 0.04150637  9307
## race_ethnicity.blBlack                            -0.0491935 0.04589533  9307
## race_ethnicity.blOther                             0.0655003 0.04196140  9307
## high.educ.blBachelor                               0.1536221 0.03529227  9307
## high.educ.blSome College                           0.1941088 0.04033107  9307
## high.educ.blHS Diploma/GED                         0.0641563 0.05660592  9307
## high.educ.bl< HS Diploma                           0.0395986 0.07349492  9307
## prnt.empl.blStay at Home Parent                   -0.0561871 0.03592320  9307
## prnt.empl.blUnemployed                             0.1410724 0.05812388  9307
## prnt.empl.blOther                                  0.1867426 0.05116620  9307
## neighb_phenx_avg_p.bl.cm                          -0.1196020 0.01495060  9307
## overall.income.bl[>=50K & <100K]                   0.0823427 0.03573809  9307
## overall.income.bl[<50k]                            0.1561066 0.04476151  9307
## overall.income.bl[Don't Know or Refuse]            0.0490506 0.05614247  9307
## sex.blFemale                                      -0.4361122 0.02617347  9307
## reshist_addr1_no2_2016_aavg_bl.c533               -0.0063955 0.00344429  9307
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.0025515 0.00301549 14510
##                                                      t-value p-value
## (Intercept)                                        11.457868  0.0000
## reshist_addr1_pm252016aa_bl.c5                     -0.335948  0.7369
## interview_age.c9.y                                 -2.986299  0.0028
## race_ethnicity.blHispanic                          -1.191544  0.2335
## race_ethnicity.blBlack                             -1.071863  0.2838
## race_ethnicity.blOther                              1.560966  0.1186
## high.educ.blBachelor                                4.352855  0.0000
## high.educ.blSome College                            4.812886  0.0000
## high.educ.blHS Diploma/GED                          1.133385  0.2571
## high.educ.bl< HS Diploma                            0.538794  0.5900
## prnt.empl.blStay at Home Parent                    -1.564090  0.1178
## prnt.empl.blUnemployed                              2.427099  0.0152
## prnt.empl.blOther                                   3.649726  0.0003
## neighb_phenx_avg_p.bl.cm                           -7.999811  0.0000
## overall.income.bl[>=50K & <100K]                    2.304059  0.0212
## overall.income.bl[<50k]                             3.487519  0.0005
## overall.income.bl[Don't Know or Refuse]             0.873681  0.3823
## sex.blFemale                                      -16.662379  0.0000
## reshist_addr1_no2_2016_aavg_bl.c533                -1.856848  0.0634
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  -0.846127  0.3975
##  Correlation: 
##                                                   (Intr) rs_1_252016_.5 in_.9.
## reshist_addr1_pm252016aa_bl.c5                    -0.384                      
## interview_age.c9.y                                -0.251  0.315               
## race_ethnicity.blHispanic                         -0.027 -0.077          0.003
## race_ethnicity.blBlack                            -0.023 -0.029          0.006
## race_ethnicity.blOther                            -0.088 -0.024          0.004
## high.educ.blBachelor                              -0.195  0.000          0.000
## high.educ.blSome College                          -0.132 -0.016          0.002
## high.educ.blHS Diploma/GED                        -0.078 -0.009          0.004
## high.educ.bl< HS Diploma                          -0.032 -0.016         -0.002
## prnt.empl.blStay at Home Parent                   -0.087 -0.017          0.001
## prnt.empl.blUnemployed                            -0.025 -0.002          0.000
## prnt.empl.blOther                                 -0.040  0.001          0.006
## neighb_phenx_avg_p.bl.cm                          -0.189  0.057         -0.003
## overall.income.bl[>=50K & <100K]                  -0.131 -0.016          0.000
## overall.income.bl[<50k]                           -0.066 -0.027         -0.001
## overall.income.bl[Don't Know or Refuse]           -0.064 -0.028         -0.002
## sex.blFemale                                      -0.185 -0.003          0.004
## reshist_addr1_no2_2016_aavg_bl.c533               -0.535 -0.234          0.003
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.218 -0.361         -0.873
##                                                   rc_t.H rc_t.B rc_t.O hgh..B
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                             0.356                     
## race_ethnicity.blOther                             0.287  0.263              
## high.educ.blBachelor                              -0.017 -0.010  0.000       
## high.educ.blSome College                          -0.106 -0.079 -0.021  0.460
## high.educ.blHS Diploma/GED                        -0.139 -0.143 -0.006  0.338
## high.educ.bl< HS Diploma                          -0.164 -0.072 -0.009  0.265
## prnt.empl.blStay at Home Parent                    0.044  0.091  0.016 -0.026
## prnt.empl.blUnemployed                             0.010 -0.041  0.010 -0.010
## prnt.empl.blOther                                  0.041  0.009 -0.014 -0.011
## neighb_phenx_avg_p.bl.cm                           0.028  0.138  0.041 -0.003
## overall.income.bl[>=50K & <100K]                  -0.089 -0.061 -0.011 -0.173
## overall.income.bl[<50k]                           -0.143 -0.184 -0.080 -0.161
## overall.income.bl[Don't Know or Refuse]           -0.097 -0.126 -0.057 -0.101
## sex.blFemale                                      -0.006 -0.017 -0.016  0.014
## reshist_addr1_no2_2016_aavg_bl.c533               -0.059 -0.084 -0.032  0.013
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.001 -0.001 -0.002 -0.001
##                                                   hg..SC h..HSD h..<HD p..aHP
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                         0.503                     
## high.educ.bl< HS Diploma                           0.410  0.379              
## prnt.empl.blStay at Home Parent                   -0.013 -0.050 -0.092       
## prnt.empl.blUnemployed                            -0.010 -0.069 -0.099  0.148
## prnt.empl.blOther                                 -0.033 -0.013 -0.020  0.158
## neighb_phenx_avg_p.bl.cm                           0.062  0.057  0.053  0.026
## overall.income.bl[>=50K & <100K]                  -0.278 -0.175 -0.114 -0.032
## overall.income.bl[<50k]                           -0.421 -0.369 -0.310 -0.054
## overall.income.bl[Don't Know or Refuse]           -0.254 -0.241 -0.219 -0.078
## sex.blFemale                                       0.021  0.014 -0.003 -0.005
## reshist_addr1_no2_2016_aavg_bl.c533                0.019  0.005 -0.018  0.008
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.001 -0.001  0.003  0.003
##                                                   prn..U prn..O n___.. o..[&<
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                  0.133                     
## neighb_phenx_avg_p.bl.cm                           0.019  0.002              
## overall.income.bl[>=50K & <100K]                  -0.016 -0.050  0.082       
## overall.income.bl[<50k]                           -0.101 -0.138  0.150  0.508
## overall.income.bl[Don't Know or Refuse]           -0.079 -0.099  0.084  0.363
## sex.blFemale                                       0.019  0.020  0.029 -0.006
## reshist_addr1_no2_2016_aavg_bl.c533               -0.012 -0.001  0.101 -0.007
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.001 -0.005  0.001 -0.001
##                                                   o..[<5 o..KoR sx.blF r_1_2_
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                                            
## neighb_phenx_avg_p.bl.cm                                                     
## overall.income.bl[>=50K & <100K]                                             
## overall.income.bl[<50k]                                                      
## overall.income.bl[Don't Know or Refuse]            0.488                     
## sex.blFemale                                      -0.008  0.006              
## reshist_addr1_no2_2016_aavg_bl.c533               -0.015 -0.001  0.000       
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.001  0.001 -0.001 -0.003
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -2.5119456 -0.7122067 -0.2814738  0.4195745  3.7883930 
## 
## Number of Observations: 23857
## Number of Groups: 
##                abcd_site subjectid %in% abcd_site 
##                       21                     9345
summary(attention_zinb_r$zi.fit)
## Linear mixed-effects model fit by maximum likelihood
##   Data: data 
##   AIC BIC logLik
##    NA  NA     NA
## 
## Random effects:
##  Formula: ~1 | abcd_site
##         (Intercept) Residual
## StdDev:   0.5614799 0.399084
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~invwt 
## Fixed effects:  zp ~ reshist_addr1_pm252016aa_bl.c5 * interview_age.c9.y + race_ethnicity.bl +      high.educ.bl + prnt.empl.bl + neighb_phenx_avg_p.bl.cm +      overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533 
##                                                       Value  Std.Error    DF
## (Intercept)                                       -5.515229 0.18061096 23817
## reshist_addr1_pm252016aa_bl.c5                     0.123391 0.03327092 23817
## interview_age.c9.y                                 0.208024 0.04337886 23817
## race_ethnicity.blHispanic                          0.277392 0.07348386 23817
## race_ethnicity.blBlack                             0.855752 0.07050106 23817
## race_ethnicity.blOther                             0.510489 0.07158396 23817
## high.educ.blBachelor                               0.063779 0.06643831 23817
## high.educ.blSome College                           0.332285 0.07321077 23817
## high.educ.blHS Diploma/GED                         1.024946 0.08689514 23817
## high.educ.bl< HS Diploma                           2.022126 0.09136890 23817
## prnt.empl.blStay at Home Parent                    0.150021 0.05547594 23817
## prnt.empl.blUnemployed                            -0.363908 0.09168686 23817
## prnt.empl.blOther                                 -0.162201 0.08711050 23817
## neighb_phenx_avg_p.bl.cm                           0.452065 0.02565896 23817
## overall.income.bl[>=50K & <100K]                  -0.361035 0.06823295 23817
## overall.income.bl[<50k]                           -0.046953 0.07611816 23817
## overall.income.bl[Don't Know or Refuse]            0.090411 0.08660639 23817
## sex.blFemale                                       0.745166 0.04423475 23817
## reshist_addr1_no2_2016_aavg_bl.c533               -0.032491 0.00600455 23817
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.020282 0.01281459 23817
##                                                      t-value p-value
## (Intercept)                                       -30.536514  0.0000
## reshist_addr1_pm252016aa_bl.c5                      3.708666  0.0002
## interview_age.c9.y                                  4.795515  0.0000
## race_ethnicity.blHispanic                           3.774872  0.0002
## race_ethnicity.blBlack                             12.138149  0.0000
## race_ethnicity.blOther                              7.131331  0.0000
## high.educ.blBachelor                                0.959979  0.3371
## high.educ.blSome College                            4.538746  0.0000
## high.educ.blHS Diploma/GED                         11.795203  0.0000
## high.educ.bl< HS Diploma                           22.131446  0.0000
## prnt.empl.blStay at Home Parent                     2.704250  0.0069
## prnt.empl.blUnemployed                             -3.969028  0.0001
## prnt.empl.blOther                                  -1.862015  0.0626
## neighb_phenx_avg_p.bl.cm                           17.618217  0.0000
## overall.income.bl[>=50K & <100K]                   -5.291206  0.0000
## overall.income.bl[<50k]                            -0.616842  0.5373
## overall.income.bl[Don't Know or Refuse]             1.043933  0.2965
## sex.blFemale                                       16.845716  0.0000
## reshist_addr1_no2_2016_aavg_bl.c533                -5.411105  0.0000
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  -1.582700  0.1135
##  Correlation: 
##                                                   (Intr) rs_1_252016_.5 in_.9.
## reshist_addr1_pm252016aa_bl.c5                    -0.449                      
## interview_age.c9.y                                -0.469  0.625               
## race_ethnicity.blHispanic                         -0.052 -0.032          0.011
## race_ethnicity.blBlack                            -0.051  0.012          0.041
## race_ethnicity.blOther                            -0.092  0.017          0.018
## high.educ.blBachelor                              -0.139 -0.002         -0.018
## high.educ.blSome College                          -0.104 -0.016          0.001
## high.educ.blHS Diploma/GED                        -0.085  0.013          0.014
## high.educ.bl< HS Diploma                          -0.052 -0.004          0.000
## prnt.empl.blStay at Home Parent                   -0.074 -0.008          0.004
## prnt.empl.blUnemployed                            -0.029  0.013          0.016
## prnt.empl.blOther                                 -0.028  0.022          0.018
## neighb_phenx_avg_p.bl.cm                          -0.133  0.026          0.004
## overall.income.bl[>=50K & <100K]                  -0.066 -0.002          0.009
## overall.income.bl[<50k]                           -0.027 -0.019         -0.011
## overall.income.bl[Don't Know or Refuse]           -0.030 -0.032          0.003
## sex.blFemale                                      -0.158 -0.015          0.005
## reshist_addr1_no2_2016_aavg_bl.c533               -0.317 -0.175          0.015
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.399 -0.710         -0.873
##                                                   rc_t.H rc_t.B rc_t.O hgh..B
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                             0.477                     
## race_ethnicity.blOther                             0.381  0.375              
## high.educ.blBachelor                              -0.006  0.007  0.019       
## high.educ.blSome College                          -0.097 -0.076 -0.006  0.485
## high.educ.blHS Diploma/GED                        -0.151 -0.143 -0.001  0.417
## high.educ.bl< HS Diploma                          -0.182 -0.103 -0.002  0.400
## prnt.empl.blStay at Home Parent                    0.047  0.095  0.035 -0.030
## prnt.empl.blUnemployed                             0.018 -0.029 -0.003 -0.018
## prnt.empl.blOther                                  0.048 -0.007 -0.017 -0.018
## neighb_phenx_avg_p.bl.cm                           0.015  0.115  0.027 -0.007
## overall.income.bl[>=50K & <100K]                  -0.088 -0.098 -0.043 -0.156
## overall.income.bl[<50k]                           -0.157 -0.215 -0.099 -0.154
## overall.income.bl[Don't Know or Refuse]           -0.129 -0.162 -0.086 -0.119
## sex.blFemale                                       0.000 -0.017 -0.013  0.006
## reshist_addr1_no2_2016_aavg_bl.c533               -0.067 -0.124 -0.063  0.011
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.004 -0.029 -0.014  0.016
##                                                   hg..SC h..HSD h..<HD p..aHP
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                         0.616                     
## high.educ.bl< HS Diploma                           0.609  0.637              
## prnt.empl.blStay at Home Parent                   -0.014 -0.047 -0.109       
## prnt.empl.blUnemployed                            -0.005 -0.059 -0.110  0.182
## prnt.empl.blOther                                 -0.017 -0.005 -0.045  0.171
## neighb_phenx_avg_p.bl.cm                           0.029  0.033  0.064  0.045
## overall.income.bl[>=50K & <100K]                  -0.310 -0.242 -0.209 -0.019
## overall.income.bl[<50k]                           -0.433 -0.450 -0.460 -0.043
## overall.income.bl[Don't Know or Refuse]           -0.324 -0.357 -0.375 -0.089
## sex.blFemale                                       0.008  0.008 -0.001  0.015
## reshist_addr1_no2_2016_aavg_bl.c533                0.024 -0.007 -0.048  0.024
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.005 -0.003  0.008  0.008
##                                                   prn..U prn..O n___.. o..[&<
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                  0.138                     
## neighb_phenx_avg_p.bl.cm                           0.033 -0.015              
## overall.income.bl[>=50K & <100K]                  -0.008 -0.041  0.048       
## overall.income.bl[<50k]                           -0.051 -0.115  0.118  0.528
## overall.income.bl[Don't Know or Refuse]           -0.055 -0.097  0.068  0.433
## sex.blFemale                                       0.038  0.012  0.016 -0.017
## reshist_addr1_no2_2016_aavg_bl.c533               -0.010 -0.016  0.090 -0.015
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.014 -0.014 -0.004 -0.006
##                                                   o..[<5 o..KoR sx.blF r_1_2_
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                                            
## neighb_phenx_avg_p.bl.cm                                                     
## overall.income.bl[>=50K & <100K]                                             
## overall.income.bl[<50k]                                                      
## overall.income.bl[Don't Know or Refuse]            0.651                     
## sex.blFemale                                      -0.008 -0.017              
## reshist_addr1_no2_2016_aavg_bl.c533               -0.045 -0.011  0.008       
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.014  0.009  0.005 -0.010
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -1.6609515 -0.2735201 -0.1785196  0.1605542 40.7544065 
## 
## Number of Observations: 23857
## Number of Groups: 21
anova(attention_zinb_r)
##                                                   numDF denDF   F-value p-value
## (Intercept)                                           1 14510 305.99064  <.0001
## reshist_addr1_pm252016aa_bl.c5                        1  9307   0.23777  0.6258
## interview_age.c9.y                                    1 14510  58.60303  <.0001
## race_ethnicity.bl                                     3  9307   4.67899  0.0029
## high.educ.bl                                          4  9307  21.82688  <.0001
## prnt.empl.bl                                          3  9307  11.50626  <.0001
## neighb_phenx_avg_p.bl.cm                              1  9307  63.43170  <.0001
## overall.income.bl                                     3  9307   4.06511  0.0068
## sex.bl                                                1  9307 277.68187  <.0001
## reshist_addr1_no2_2016_aavg_bl.c533                   1  9307   3.45771  0.0630
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y     1 14510   0.71593  0.3975

Assumption checking for ZINB Models

#Check outlier/residuals with this df
attention_res <- df_cc
attention_res$level1_resid.raw <- residuals(attention_zinb_r)
attention_res$level1_resid.pearson <- residuals(attention_zinb_r, type="pearson")
#Add predicted values (Yhat)
attention_res$cbcl_scr_syn_attention_r_predicted <- predict(attention_zinb_r,attention_res,type="response")
#Incidence
attention_res$incidence <- estimate.probability(attention_res$cbcl_scr_syn_attention_r, method="empirical")

#Plotting histogram of residuals, but may be skewed since using ZINB, so make sure to check below plots
hist(attention_res$level1_resid.pearson)

### Incidence vs. X’s Plots

#age
ggplot(attention_res,aes(incidence,interview_age)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

#pm2.5
ggplot(attention_res,aes(incidence,reshist_addr1_pm252016aa_bl)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

### Residuals vs Y (CBCL Outcome) Plot

plot(attention_res$level1_resid.pearson, attention_res$cbcl_scr_syn_attention_r)

### Residuals vs Yhat Plot

plot(attention_res$level1_resid.pearson, attention_res$cbcl_scr_syn_attention_r_predicted)

### Residuals vs Row Plot

plot(as.numeric(rownames(attention_res)),attention_res$level1_resid.pearson)

### Residuals vs X’s Plots

#age
ggplot(attention_res,aes(level1_resid.pearson,interview_age)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

#pm2.5
ggplot(attention_res,aes(level1_resid.pearson,reshist_addr1_pm252016aa_bl)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

Rulebreak

CBCL + AP Longitudinal Models

rulebreak_zinb_r <- glmm.zinb(cbcl_scr_syn_rulebreak_r ~ reshist_addr1_pm252016aa_bl.c5*interview_age.c9.y + race_ethnicity.bl + high.educ.bl+ prnt.empl.bl  + neighb_phenx_avg_p.bl.cm + overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533, random = ~1|abcd_site/subjectid,
              zi_fixed = ~ reshist_addr1_pm252016aa_bl.c5*interview_age.c9.y + race_ethnicity.bl + high.educ.bl+ prnt.empl.bl  + neighb_phenx_avg_p.bl.cm + overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533, zi_random = ~1|abcd_site, data = df_cc)
## Computational iterations: 15 
## Computational time: 2.39 minutes
summary(rulebreak_zinb_r)
## Linear mixed-effects model fit by maximum likelihood
##   Data: df_cc 
##   AIC BIC logLik
##    NA  NA     NA
## 
## Random effects:
##  Formula: ~1 | abcd_site
##         (Intercept)
## StdDev:   0.1319985
## 
##  Formula: ~1 | subjectid %in% abcd_site
##         (Intercept)  Residual
## StdDev:    1.193222 0.7910848
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~invwt 
## Fixed effects:  cbcl_scr_syn_rulebreak_r ~ reshist_addr1_pm252016aa_bl.c5 * interview_age.c9.y +      race_ethnicity.bl + high.educ.bl + prnt.empl.bl + neighb_phenx_avg_p.bl.cm +      overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533 
##                                                        Value  Std.Error    DF
## (Intercept)                                       -0.4608865 0.07201545 14510
## reshist_addr1_pm252016aa_bl.c5                    -0.0086035 0.01574688  9307
## interview_age.c9.y                                -0.0111185 0.01307453 14510
## race_ethnicity.blHispanic                         -0.0625569 0.04606489  9307
## race_ethnicity.blBlack                             0.1011862 0.05032717  9307
## race_ethnicity.blOther                             0.0854988 0.04677108  9307
## high.educ.blBachelor                               0.1800712 0.03982702  9307
## high.educ.blSome College                           0.3288204 0.04485979  9307
## high.educ.blHS Diploma/GED                         0.1893917 0.06237381  9307
## high.educ.bl< HS Diploma                           0.2308833 0.08012045  9307
## prnt.empl.blStay at Home Parent                   -0.0324430 0.04008399  9307
## prnt.empl.blUnemployed                             0.1794433 0.06335055  9307
## prnt.empl.blOther                                  0.2562250 0.05599409  9307
## neighb_phenx_avg_p.bl.cm                          -0.1236551 0.01651205  9307
## overall.income.bl[>=50K & <100K]                   0.1495291 0.04016566  9307
## overall.income.bl[<50k]                            0.3314525 0.04959594  9307
## overall.income.bl[Don't Know or Refuse]            0.2610857 0.06199701  9307
## sex.blFemale                                      -0.4244973 0.02922905  9307
## reshist_addr1_no2_2016_aavg_bl.c533               -0.0055482 0.00376578  9307
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.0073172 0.00406477 14510
##                                                      t-value p-value
## (Intercept)                                        -6.399828  0.0000
## reshist_addr1_pm252016aa_bl.c5                     -0.546362  0.5848
## interview_age.c9.y                                 -0.850393  0.3951
## race_ethnicity.blHispanic                          -1.358017  0.1745
## race_ethnicity.blBlack                              2.010569  0.0444
## race_ethnicity.blOther                              1.828028  0.0676
## high.educ.blBachelor                                4.521333  0.0000
## high.educ.blSome College                            7.329958  0.0000
## high.educ.blHS Diploma/GED                          3.036398  0.0024
## high.educ.bl< HS Diploma                            2.881703  0.0040
## prnt.empl.blStay at Home Parent                    -0.809376  0.4183
## prnt.empl.blUnemployed                              2.832545  0.0046
## prnt.empl.blOther                                   4.575929  0.0000
## neighb_phenx_avg_p.bl.cm                           -7.488779  0.0000
## overall.income.bl[>=50K & <100K]                    3.722810  0.0002
## overall.income.bl[<50k]                             6.683056  0.0000
## overall.income.bl[Don't Know or Refuse]             4.211262  0.0000
## sex.blFemale                                      -14.523131  0.0000
## reshist_addr1_no2_2016_aavg_bl.c533                -1.473311  0.1407
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  -1.800149  0.0719
##  Correlation: 
##                                                   (Intr) rs_1_252016_.5 in_.9.
## reshist_addr1_pm252016aa_bl.c5                    -0.410                      
## interview_age.c9.y                                -0.315  0.381               
## race_ethnicity.blHispanic                         -0.020 -0.083          0.004
## race_ethnicity.blBlack                            -0.022 -0.037          0.008
## race_ethnicity.blOther                            -0.089 -0.031          0.004
## high.educ.blBachelor                              -0.202  0.000          0.000
## high.educ.blSome College                          -0.143 -0.016          0.002
## high.educ.blHS Diploma/GED                        -0.086 -0.008          0.005
## high.educ.bl< HS Diploma                          -0.038 -0.016         -0.002
## prnt.empl.blStay at Home Parent                   -0.084 -0.018          0.002
## prnt.empl.blUnemployed                            -0.025 -0.003          0.000
## prnt.empl.blOther                                 -0.040  0.002          0.008
## neighb_phenx_avg_p.bl.cm                          -0.189  0.058         -0.003
## overall.income.bl[>=50K & <100K]                  -0.140 -0.014          0.001
## overall.income.bl[<50k]                           -0.075 -0.027         -0.001
## overall.income.bl[Don't Know or Refuse]           -0.071 -0.027         -0.002
## sex.blFemale                                      -0.181 -0.006          0.004
## reshist_addr1_no2_2016_aavg_bl.c533               -0.541 -0.213          0.003
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.273 -0.436         -0.873
##                                                   rc_t.H rc_t.B rc_t.O hgh..B
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                             0.367                     
## race_ethnicity.blOther                             0.293  0.273              
## high.educ.blBachelor                              -0.020 -0.012  0.001       
## high.educ.blSome College                          -0.106 -0.080 -0.021  0.473
## high.educ.blHS Diploma/GED                        -0.143 -0.146 -0.008  0.351
## high.educ.bl< HS Diploma                          -0.167 -0.076 -0.011  0.278
## prnt.empl.blStay at Home Parent                    0.043  0.093  0.016 -0.030
## prnt.empl.blUnemployed                             0.012 -0.038  0.010 -0.008
## prnt.empl.blOther                                  0.047  0.016 -0.011 -0.013
## neighb_phenx_avg_p.bl.cm                           0.034  0.140  0.046 -0.003
## overall.income.bl[>=50K & <100K]                  -0.091 -0.066 -0.015 -0.171
## overall.income.bl[<50k]                           -0.146 -0.186 -0.080 -0.161
## overall.income.bl[Don't Know or Refuse]           -0.101 -0.128 -0.057 -0.101
## sex.blFemale                                      -0.008 -0.019 -0.016  0.011
## reshist_addr1_no2_2016_aavg_bl.c533               -0.063 -0.084 -0.029  0.012
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.000 -0.002 -0.002 -0.002
##                                                   hg..SC h..HSD h..<HD p..aHP
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                         0.516                     
## high.educ.bl< HS Diploma                           0.423  0.389              
## prnt.empl.blStay at Home Parent                   -0.016 -0.051 -0.099       
## prnt.empl.blUnemployed                            -0.008 -0.068 -0.100  0.152
## prnt.empl.blOther                                 -0.034 -0.016 -0.023  0.162
## neighb_phenx_avg_p.bl.cm                           0.061  0.054  0.050  0.030
## overall.income.bl[>=50K & <100K]                  -0.275 -0.175 -0.116 -0.028
## overall.income.bl[<50k]                           -0.420 -0.367 -0.310 -0.050
## overall.income.bl[Don't Know or Refuse]           -0.258 -0.244 -0.222 -0.070
## sex.blFemale                                       0.022  0.014 -0.003 -0.007
## reshist_addr1_no2_2016_aavg_bl.c533                0.022  0.007 -0.015  0.002
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.001 -0.001  0.003  0.004
##                                                   prn..U prn..O n___.. o..[&<
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                  0.138                     
## neighb_phenx_avg_p.bl.cm                           0.023  0.003              
## overall.income.bl[>=50K & <100K]                  -0.015 -0.049  0.079       
## overall.income.bl[<50k]                           -0.102 -0.140  0.151  0.519
## overall.income.bl[Don't Know or Refuse]           -0.082 -0.101  0.084  0.375
## sex.blFemale                                       0.014  0.017  0.031 -0.010
## reshist_addr1_no2_2016_aavg_bl.c533               -0.013 -0.004  0.099 -0.006
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.001 -0.007  0.001 -0.002
##                                                   o..[<5 o..KoR sx.blF r_1_2_
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                                            
## neighb_phenx_avg_p.bl.cm                                                     
## overall.income.bl[>=50K & <100K]                                             
## overall.income.bl[<50k]                                                      
## overall.income.bl[Don't Know or Refuse]            0.503                     
## sex.blFemale                                      -0.010  0.004              
## reshist_addr1_no2_2016_aavg_bl.c533               -0.011  0.000  0.002       
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.001  0.002  0.000 -0.003
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -2.9548528 -0.6410680 -0.4932774  0.3944843  3.9742633 
## 
## Number of Observations: 23857
## Number of Groups: 
##                abcd_site subjectid %in% abcd_site 
##                       21                     9345
summary(rulebreak_zinb_r$zi.fit)
## Linear mixed-effects model fit by maximum likelihood
##   Data: data 
##   AIC BIC logLik
##    NA  NA     NA
## 
## Random effects:
##  Formula: ~1 | abcd_site
##         (Intercept)  Residual
## StdDev:   0.4646952 0.2627375
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~invwt 
## Fixed effects:  zp ~ reshist_addr1_pm252016aa_bl.c5 * interview_age.c9.y + race_ethnicity.bl +      high.educ.bl + prnt.empl.bl + neighb_phenx_avg_p.bl.cm +      overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533 
##                                                       Value  Std.Error    DF
## (Intercept)                                       -4.858859 0.12108106 23817
## reshist_addr1_pm252016aa_bl.c5                    -0.030596 0.01800879 23817
## interview_age.c9.y                                 0.233989 0.01942862 23817
## race_ethnicity.blHispanic                          0.189782 0.03463825 23817
## race_ethnicity.blBlack                            -0.218182 0.04808695 23817
## race_ethnicity.blOther                            -0.036684 0.03540483 23817
## high.educ.blBachelor                              -0.254884 0.02764554 23817
## high.educ.blSome College                          -0.638935 0.03767951 23817
## high.educ.blHS Diploma/GED                        -0.130831 0.04971140 23817
## high.educ.bl< HS Diploma                           0.014054 0.05841238 23817
## prnt.empl.blStay at Home Parent                   -0.004982 0.02979314 23817
## prnt.empl.blUnemployed                            -0.163256 0.05885508 23817
## prnt.empl.blOther                                 -0.072334 0.04961089 23817
## neighb_phenx_avg_p.bl.cm                           0.387341 0.01464331 23817
## overall.income.bl[>=50K & <100K]                  -0.277322 0.03047146 23817
## overall.income.bl[<50k]                           -0.018113 0.03917084 23817
## overall.income.bl[Don't Know or Refuse]            0.410501 0.04187221 23817
## sex.blFemale                                       1.210516 0.02444207 23817
## reshist_addr1_no2_2016_aavg_bl.c533                0.014326 0.00329089 23817
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.009678 0.00644513 23817
##                                                     t-value p-value
## (Intercept)                                       -40.12898  0.0000
## reshist_addr1_pm252016aa_bl.c5                     -1.69894  0.0893
## interview_age.c9.y                                 12.04351  0.0000
## race_ethnicity.blHispanic                           5.47897  0.0000
## race_ethnicity.blBlack                             -4.53725  0.0000
## race_ethnicity.blOther                             -1.03613  0.3002
## high.educ.blBachelor                               -9.21973  0.0000
## high.educ.blSome College                          -16.95710  0.0000
## high.educ.blHS Diploma/GED                         -2.63180  0.0085
## high.educ.bl< HS Diploma                            0.24059  0.8099
## prnt.empl.blStay at Home Parent                    -0.16723  0.8672
## prnt.empl.blUnemployed                             -2.77386  0.0055
## prnt.empl.blOther                                  -1.45804  0.1448
## neighb_phenx_avg_p.bl.cm                           26.45174  0.0000
## overall.income.bl[>=50K & <100K]                   -9.10102  0.0000
## overall.income.bl[<50k]                            -0.46240  0.6438
## overall.income.bl[Don't Know or Refuse]             9.80366  0.0000
## sex.blFemale                                       49.52589  0.0000
## reshist_addr1_no2_2016_aavg_bl.c533                 4.35330  0.0000
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y   1.50160  0.1332
##  Correlation: 
##                                                   (Intr) rs_1_252016_.5 in_.9.
## reshist_addr1_pm252016aa_bl.c5                    -0.304                      
## interview_age.c9.y                                -0.326  0.593               
## race_ethnicity.blHispanic                         -0.024 -0.032          0.011
## race_ethnicity.blBlack                            -0.019  0.006          0.024
## race_ethnicity.blOther                            -0.049  0.009          0.009
## high.educ.blBachelor                              -0.066 -0.004         -0.016
## high.educ.blSome College                          -0.035 -0.012         -0.006
## high.educ.blHS Diploma/GED                        -0.017 -0.005          0.006
## high.educ.bl< HS Diploma                           0.013 -0.047         -0.018
## prnt.empl.blStay at Home Parent                   -0.042 -0.020         -0.002
## prnt.empl.blUnemployed                            -0.013 -0.010         -0.005
## prnt.empl.blOther                                 -0.017  0.017          0.011
## neighb_phenx_avg_p.bl.cm                          -0.121  0.033          0.006
## overall.income.bl[>=50K & <100K]                  -0.054  0.003          0.004
## overall.income.bl[<50k]                           -0.024 -0.007          0.001
## overall.income.bl[Don't Know or Refuse]           -0.030 -0.015          0.005
## sex.blFemale                                      -0.153 -0.007          0.009
## reshist_addr1_no2_2016_aavg_bl.c533               -0.270 -0.204          0.006
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.271 -0.718         -0.833
##                                                   rc_t.H rc_t.B rc_t.O hgh..B
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                             0.285                     
## race_ethnicity.blOther                             0.289  0.180              
## high.educ.blBachelor                              -0.004 -0.007  0.009       
## high.educ.blSome College                          -0.128 -0.086 -0.002  0.342
## high.educ.blHS Diploma/GED                        -0.183 -0.134  0.001  0.270
## high.educ.bl< HS Diploma                          -0.199 -0.080  0.010  0.237
## prnt.empl.blStay at Home Parent                    0.048  0.074  0.012 -0.042
## prnt.empl.blUnemployed                             0.001 -0.038  0.004 -0.017
## prnt.empl.blOther                                  0.030 -0.013 -0.025 -0.030
## neighb_phenx_avg_p.bl.cm                           0.017  0.084  0.020 -0.013
## overall.income.bl[>=50K & <100K]                  -0.089 -0.057 -0.016 -0.143
## overall.income.bl[<50k]                           -0.128 -0.144 -0.065 -0.145
## overall.income.bl[Don't Know or Refuse]           -0.094 -0.096 -0.067 -0.094
## sex.blFemale                                      -0.003 -0.012 -0.015  0.005
## reshist_addr1_no2_2016_aavg_bl.c533               -0.048 -0.077 -0.024  0.013
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.003 -0.013 -0.009  0.010
##                                                   hg..SC h..HSD h..<HD p..aHP
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                         0.405                     
## high.educ.bl< HS Diploma                           0.379  0.403              
## prnt.empl.blStay at Home Parent                   -0.030 -0.075 -0.129       
## prnt.empl.blUnemployed                            -0.015 -0.056 -0.097  0.132
## prnt.empl.blOther                                 -0.026  0.005 -0.029  0.137
## neighb_phenx_avg_p.bl.cm                           0.039  0.039  0.053  0.025
## overall.income.bl[>=50K & <100K]                  -0.220 -0.134 -0.091 -0.014
## overall.income.bl[<50k]                           -0.382 -0.392 -0.355 -0.018
## overall.income.bl[Don't Know or Refuse]           -0.227 -0.264 -0.241 -0.082
## sex.blFemale                                       0.004 -0.003 -0.012  0.001
## reshist_addr1_no2_2016_aavg_bl.c533                0.017 -0.007 -0.026  0.017
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.002  0.002  0.025  0.015
##                                                   prn..U prn..O n___.. o..[&<
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                  0.099                     
## neighb_phenx_avg_p.bl.cm                           0.027  0.001              
## overall.income.bl[>=50K & <100K]                  -0.009 -0.051  0.089       
## overall.income.bl[<50k]                           -0.069 -0.132  0.113  0.383
## overall.income.bl[Don't Know or Refuse]           -0.059 -0.099  0.072  0.301
## sex.blFemale                                       0.026  0.010  0.034 -0.014
## reshist_addr1_no2_2016_aavg_bl.c533               -0.006 -0.014  0.124  0.000
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.010 -0.011 -0.006  0.000
##                                                   o..[<5 o..KoR sx.blF r_1_2_
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                                            
## neighb_phenx_avg_p.bl.cm                                                     
## overall.income.bl[>=50K & <100K]                                             
## overall.income.bl[<50k]                                                      
## overall.income.bl[Don't Know or Refuse]            0.456                     
## sex.blFemale                                      -0.004  0.016              
## reshist_addr1_no2_2016_aavg_bl.c533               -0.026 -0.004  0.010       
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.001 -0.002  0.002 -0.009
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -2.0220695 -0.4361089  0.1495185  0.2581541 45.5351413 
## 
## Number of Observations: 23857
## Number of Groups: 21
anova(rulebreak_zinb_r)
##                                                   numDF denDF   F-value p-value
## (Intercept)                                           1 14510 175.30571  <.0001
## reshist_addr1_pm252016aa_bl.c5                        1  9307   1.45330  0.2280
## interview_age.c9.y                                    1 14510  26.62996  <.0001
## race_ethnicity.bl                                     3  9307  30.05610  <.0001
## high.educ.bl                                          4  9307  50.15661  <.0001
## prnt.empl.bl                                          3  9307  16.73595  <.0001
## neighb_phenx_avg_p.bl.cm                              1  9307  64.61592  <.0001
## overall.income.bl                                     3  9307  14.60484  <.0001
## sex.bl                                                1  9307 210.84597  <.0001
## reshist_addr1_no2_2016_aavg_bl.c533                   1  9307   2.18877  0.1391
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y     1 14510   3.24054  0.0719

Assumption checking for ZINB Models

#Check outlier/residuals with this df
rulebreak_res <- df_cc
rulebreak_res$level1_resid.raw <- residuals(rulebreak_zinb_r)
rulebreak_res$level1_resid.pearson <- residuals(rulebreak_zinb_r, type="pearson")
#Add predicted values (Yhat)
rulebreak_res$cbcl_scr_syn_rulebreak_r_predicted <- predict(rulebreak_zinb_r,rulebreak_res,type="response")
#Incidence
rulebreak_res$incidence <- estimate.probability(rulebreak_res$cbcl_scr_syn_rulebreak_r, method="empirical")

#Plotting histogram of residuals, but may be skewed since using ZINB, so make sure to check below plots
hist(rulebreak_res$level1_resid.pearson)

### Incidence vs. X’s Plots

#age
ggplot(rulebreak_res,aes(incidence,interview_age)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
## : pseudoinverse used at 0
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
## : neighborhood radius 7.303e-05
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
## : reciprocal condition number 1.3261e-14
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
## : There are other near singularities as well. 1.3333e-09
## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
## else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at 0
## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
## else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
## 7.303e-05
## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
## else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
## number 1.3261e-14
## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
## else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : There are other near
## singularities as well. 1.3333e-09

#pm2.5
ggplot(rulebreak_res,aes(incidence,reshist_addr1_pm252016aa_bl)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
## : pseudoinverse used at 0
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
## : neighborhood radius 7.303e-05
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
## : reciprocal condition number 1.3261e-14
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
## : There are other near singularities as well. 1.3333e-09
## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
## else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at 0
## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
## else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
## 7.303e-05
## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
## else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
## number 1.3261e-14
## Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
## else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : There are other near
## singularities as well. 1.3333e-09

### Residuals vs Y (CBCL Outcome) Plot

plot(rulebreak_res$level1_resid.pearson, rulebreak_res$cbcl_scr_syn_rulebreak_r)

### Residuals vs Yhat Plot

plot(rulebreak_res$level1_resid.pearson, rulebreak_res$cbcl_scr_syn_rulebreak_r_predicted)

### Residuals vs Row Plot

plot(as.numeric(rownames(rulebreak_res)),rulebreak_res$level1_resid.pearson)

### Residuals vs X’s Plots

#age
ggplot(rulebreak_res,aes(level1_resid.pearson,interview_age)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

#pm2.5
ggplot(rulebreak_res,aes(level1_resid.pearson,reshist_addr1_pm252016aa_bl)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

Aggressive

CBCL + AP Longitudinal Models

aggressive_zinb_r <- glmm.zinb(cbcl_scr_syn_aggressive_r ~ reshist_addr1_pm252016aa_bl.c5*interview_age.c9.y + race_ethnicity.bl + high.educ.bl+ prnt.empl.bl  + neighb_phenx_avg_p.bl.cm + overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533, random = ~1|abcd_site/subjectid,
              zi_fixed = ~ reshist_addr1_pm252016aa_bl.c5*interview_age.c9.y + race_ethnicity.bl + high.educ.bl+ prnt.empl.bl  + neighb_phenx_avg_p.bl.cm + overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533, zi_random = ~1|abcd_site, data = df_cc)
## Computational iterations: 11 
## Computational time: 1.733 minutes
summary(aggressive_zinb_r)
## Linear mixed-effects model fit by maximum likelihood
##   Data: df_cc 
##   AIC BIC logLik
##    NA  NA     NA
## 
## Random effects:
##  Formula: ~1 | abcd_site
##         (Intercept)
## StdDev:   0.1353382
## 
##  Formula: ~1 | subjectid %in% abcd_site
##         (Intercept)  Residual
## StdDev:    1.145622 0.9763728
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~invwt 
## Fixed effects:  cbcl_scr_syn_aggressive_r ~ reshist_addr1_pm252016aa_bl.c5 *      interview_age.c9.y + race_ethnicity.bl + high.educ.bl + prnt.empl.bl +      neighb_phenx_avg_p.bl.cm + overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533 
##                                                        Value  Std.Error    DF
## (Intercept)                                        0.7125267 0.06613630 14510
## reshist_addr1_pm252016aa_bl.c5                    -0.0079460 0.01430213  9307
## interview_age.c9.y                                -0.0289695 0.00994498 14510
## race_ethnicity.blHispanic                         -0.0506505 0.04198298  9307
## race_ethnicity.blBlack                            -0.1868707 0.04674669  9307
## race_ethnicity.blOther                            -0.0837799 0.04281735  9307
## high.educ.blBachelor                               0.0872491 0.03579956  9307
## high.educ.blSome College                           0.1510548 0.04084542  9307
## high.educ.blHS Diploma/GED                         0.0261277 0.05734511  9307
## high.educ.bl< HS Diploma                           0.0932123 0.07377417  9307
## prnt.empl.blStay at Home Parent                    0.0250469 0.03624081  9307
## prnt.empl.blUnemployed                             0.2143845 0.05878427  9307
## prnt.empl.blOther                                  0.1827674 0.05189617  9307
## neighb_phenx_avg_p.bl.cm                          -0.1278335 0.01512435  9307
## overall.income.bl[>=50K & <100K]                   0.1229781 0.03618114  9307
## overall.income.bl[<50k]                            0.2496497 0.04526850  9307
## overall.income.bl[Don't Know or Refuse]            0.1385538 0.05688246  9307
## sex.blFemale                                      -0.2494005 0.02647986  9307
## reshist_addr1_no2_2016_aavg_bl.c533               -0.0049382 0.00348323  9307
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.0055511 0.00315186 14510
##                                                     t-value p-value
## (Intercept)                                       10.773610  0.0000
## reshist_addr1_pm252016aa_bl.c5                    -0.555580  0.5785
## interview_age.c9.y                                -2.912975  0.0036
## race_ethnicity.blHispanic                         -1.206454  0.2277
## race_ethnicity.blBlack                            -3.997518  0.0001
## race_ethnicity.blOther                            -1.956681  0.0504
## high.educ.blBachelor                               2.437155  0.0148
## high.educ.blSome College                           3.698206  0.0002
## high.educ.blHS Diploma/GED                         0.455623  0.6487
## high.educ.bl< HS Diploma                           1.263481  0.2064
## prnt.empl.blStay at Home Parent                    0.691125  0.4895
## prnt.empl.blUnemployed                             3.646970  0.0003
## prnt.empl.blOther                                  3.521790  0.0004
## neighb_phenx_avg_p.bl.cm                          -8.452168  0.0000
## overall.income.bl[>=50K & <100K]                   3.398957  0.0007
## overall.income.bl[<50k]                            5.514867  0.0000
## overall.income.bl[Don't Know or Refuse]            2.435792  0.0149
## sex.blFemale                                      -9.418498  0.0000
## reshist_addr1_no2_2016_aavg_bl.c533               -1.417718  0.1563
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -1.761213  0.0782
##  Correlation: 
##                                                   (Intr) rs_1_252016_.5 in_.9.
## reshist_addr1_pm252016aa_bl.c5                    -0.385                      
## interview_age.c9.y                                -0.260  0.322               
## race_ethnicity.blHispanic                         -0.024 -0.078          0.004
## race_ethnicity.blBlack                            -0.022 -0.029          0.006
## race_ethnicity.blOther                            -0.086 -0.023          0.003
## high.educ.blBachelor                              -0.195  0.002          0.000
## high.educ.blSome College                          -0.132 -0.016          0.002
## high.educ.blHS Diploma/GED                        -0.080 -0.008          0.004
## high.educ.bl< HS Diploma                          -0.032 -0.016         -0.001
## prnt.empl.blStay at Home Parent                   -0.085 -0.018          0.002
## prnt.empl.blUnemployed                            -0.026 -0.003          0.000
## prnt.empl.blOther                                 -0.039  0.001          0.006
## neighb_phenx_avg_p.bl.cm                          -0.186  0.058         -0.002
## overall.income.bl[>=50K & <100K]                  -0.131 -0.016          0.000
## overall.income.bl[<50k]                           -0.066 -0.029         -0.001
## overall.income.bl[Don't Know or Refuse]           -0.063 -0.030         -0.002
## sex.blFemale                                      -0.187 -0.003          0.003
## reshist_addr1_no2_2016_aavg_bl.c533               -0.533 -0.236          0.003
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.224 -0.370         -0.869
##                                                   rc_t.H rc_t.B rc_t.O hgh..B
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                             0.355                     
## race_ethnicity.blOther                             0.287  0.261              
## high.educ.blBachelor                              -0.022 -0.017 -0.003       
## high.educ.blSome College                          -0.112 -0.086 -0.026  0.461
## high.educ.blHS Diploma/GED                        -0.144 -0.148 -0.010  0.339
## high.educ.bl< HS Diploma                          -0.169 -0.078 -0.013  0.268
## prnt.empl.blStay at Home Parent                    0.043  0.092  0.018 -0.031
## prnt.empl.blUnemployed                             0.010 -0.041  0.011 -0.010
## prnt.empl.blOther                                  0.040  0.011 -0.011 -0.014
## neighb_phenx_avg_p.bl.cm                           0.029  0.137  0.041 -0.005
## overall.income.bl[>=50K & <100K]                  -0.087 -0.060 -0.010 -0.176
## overall.income.bl[<50k]                           -0.141 -0.180 -0.079 -0.161
## overall.income.bl[Don't Know or Refuse]           -0.095 -0.123 -0.055 -0.101
## sex.blFemale                                      -0.008 -0.018 -0.019  0.014
## reshist_addr1_no2_2016_aavg_bl.c533               -0.059 -0.083 -0.032  0.015
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.000 -0.001 -0.002 -0.001
##                                                   hg..SC h..HSD h..<HD p..aHP
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                         0.502                     
## high.educ.bl< HS Diploma                           0.413  0.381              
## prnt.empl.blStay at Home Parent                   -0.016 -0.050 -0.095       
## prnt.empl.blUnemployed                            -0.011 -0.069 -0.099  0.149
## prnt.empl.blOther                                 -0.033 -0.014 -0.020  0.159
## neighb_phenx_avg_p.bl.cm                           0.061  0.056  0.049  0.028
## overall.income.bl[>=50K & <100K]                  -0.276 -0.174 -0.116 -0.028
## overall.income.bl[<50k]                           -0.417 -0.367 -0.311 -0.052
## overall.income.bl[Don't Know or Refuse]           -0.253 -0.240 -0.220 -0.075
## sex.blFemale                                       0.021  0.014 -0.005 -0.006
## reshist_addr1_no2_2016_aavg_bl.c533                0.021  0.008 -0.016  0.006
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.001 -0.001  0.002  0.003
##                                                   prn..U prn..O n___.. o..[&<
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                  0.134                     
## neighb_phenx_avg_p.bl.cm                           0.022  0.004              
## overall.income.bl[>=50K & <100K]                  -0.014 -0.048  0.080       
## overall.income.bl[<50k]                           -0.100 -0.138  0.151  0.508
## overall.income.bl[Don't Know or Refuse]           -0.077 -0.097  0.083  0.363
## sex.blFemale                                       0.019  0.017  0.027 -0.005
## reshist_addr1_no2_2016_aavg_bl.c533               -0.011 -0.002  0.098 -0.010
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.002 -0.006  0.000 -0.001
##                                                   o..[<5 o..KoR sx.blF r_1_2_
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                                            
## neighb_phenx_avg_p.bl.cm                                                     
## overall.income.bl[>=50K & <100K]                                             
## overall.income.bl[<50k]                                                      
## overall.income.bl[Don't Know or Refuse]            0.488                     
## sex.blFemale                                      -0.006  0.009              
## reshist_addr1_no2_2016_aavg_bl.c533               -0.017 -0.004 -0.001       
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.001  0.002  0.000 -0.003
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -3.4152997 -0.7126800 -0.3414064  0.4036700  4.0640651 
## 
## Number of Observations: 23857
## Number of Groups: 
##                abcd_site subjectid %in% abcd_site 
##                       21                     9345
summary(aggressive_zinb_r$zi.fit)
## Linear mixed-effects model fit by maximum likelihood
##   Data: data 
##   AIC BIC logLik
##    NA  NA     NA
## 
## Random effects:
##  Formula: ~1 | abcd_site
##         (Intercept)  Residual
## StdDev:   0.2872063 0.4680178
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~invwt 
## Fixed effects:  zp ~ reshist_addr1_pm252016aa_bl.c5 * interview_age.c9.y + race_ethnicity.bl +      high.educ.bl + prnt.empl.bl + neighb_phenx_avg_p.bl.cm +      overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533 
##                                                       Value  Std.Error    DF
## (Intercept)                                       -4.562223 0.12721169 23817
## reshist_addr1_pm252016aa_bl.c5                     0.111760 0.02877556 23817
## interview_age.c9.y                                 0.311412 0.03539220 23817
## race_ethnicity.blHispanic                          0.355667 0.05967951 23817
## race_ethnicity.blBlack                             0.726116 0.06154681 23817
## race_ethnicity.blOther                             0.464283 0.05665542 23817
## high.educ.blBachelor                               0.145535 0.04969539 23817
## high.educ.blSome College                           0.229520 0.05834128 23817
## high.educ.blHS Diploma/GED                         0.389079 0.08006616 23817
## high.educ.bl< HS Diploma                           1.018741 0.08726699 23817
## prnt.empl.blStay at Home Parent                   -0.034355 0.05173919 23817
## prnt.empl.blUnemployed                             0.231090 0.07356334 23817
## prnt.empl.blOther                                 -0.160481 0.07944159 23817
## neighb_phenx_avg_p.bl.cm                           0.265650 0.02231635 23817
## overall.income.bl[>=50K & <100K]                  -0.296345 0.05187634 23817
## overall.income.bl[<50k]                           -0.538582 0.06532682 23817
## overall.income.bl[Don't Know or Refuse]            0.038402 0.07166424 23817
## sex.blFemale                                       0.202557 0.03645698 23817
## reshist_addr1_no2_2016_aavg_bl.c533               -0.004932 0.00516650 23817
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.024467 0.01086372 23817
##                                                     t-value p-value
## (Intercept)                                       -35.86324  0.0000
## reshist_addr1_pm252016aa_bl.c5                      3.88385  0.0001
## interview_age.c9.y                                  8.79890  0.0000
## race_ethnicity.blHispanic                           5.95962  0.0000
## race_ethnicity.blBlack                             11.79779  0.0000
## race_ethnicity.blOther                              8.19486  0.0000
## high.educ.blBachelor                                2.92855  0.0034
## high.educ.blSome College                            3.93409  0.0001
## high.educ.blHS Diploma/GED                          4.85947  0.0000
## high.educ.bl< HS Diploma                           11.67385  0.0000
## prnt.empl.blStay at Home Parent                    -0.66400  0.5067
## prnt.empl.blUnemployed                              3.14137  0.0017
## prnt.empl.blOther                                  -2.02012  0.0434
## neighb_phenx_avg_p.bl.cm                           11.90385  0.0000
## overall.income.bl[>=50K & <100K]                   -5.71252  0.0000
## overall.income.bl[<50k]                            -8.24443  0.0000
## overall.income.bl[Don't Know or Refuse]             0.53586  0.5921
## sex.blFemale                                        5.55606  0.0000
## reshist_addr1_no2_2016_aavg_bl.c533                -0.95465  0.3398
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  -2.25217  0.0243
##  Correlation: 
##                                                   (Intr) rs_1_252016_.5 in_.9.
## reshist_addr1_pm252016aa_bl.c5                    -0.532                      
## interview_age.c9.y                                -0.570  0.645               
## race_ethnicity.blHispanic                         -0.048 -0.040          0.007
## race_ethnicity.blBlack                            -0.045 -0.002          0.032
## race_ethnicity.blOther                            -0.098  0.004          0.012
## high.educ.blBachelor                              -0.153 -0.001         -0.007
## high.educ.blSome College                          -0.108 -0.008          0.003
## high.educ.blHS Diploma/GED                        -0.075  0.007          0.017
## high.educ.bl< HS Diploma                          -0.028 -0.030         -0.008
## prnt.empl.blStay at Home Parent                   -0.075 -0.008          0.005
## prnt.empl.blUnemployed                            -0.031  0.002          0.006
## prnt.empl.blOther                                 -0.032  0.015          0.018
## neighb_phenx_avg_p.bl.cm                          -0.167  0.036          0.005
## overall.income.bl[>=50K & <100K]                  -0.072 -0.009         -0.001
## overall.income.bl[<50k]                           -0.025 -0.022         -0.011
## overall.income.bl[Don't Know or Refuse]           -0.031 -0.036         -0.007
## sex.blFemale                                      -0.157 -0.004          0.009
## reshist_addr1_no2_2016_aavg_bl.c533               -0.407 -0.172          0.007
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.481 -0.741         -0.860
##                                                   rc_t.H rc_t.B rc_t.O hgh..B
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                             0.408                     
## race_ethnicity.blOther                             0.340  0.308              
## high.educ.blBachelor                              -0.006 -0.003  0.018       
## high.educ.blSome College                          -0.114 -0.093 -0.005  0.452
## high.educ.blHS Diploma/GED                        -0.142 -0.145  0.005  0.340
## high.educ.bl< HS Diploma                          -0.169 -0.090  0.002  0.317
## prnt.empl.blStay at Home Parent                    0.048  0.100  0.021 -0.029
## prnt.empl.blUnemployed                             0.018 -0.027  0.014 -0.016
## prnt.empl.blOther                                  0.042  0.003 -0.019 -0.020
## neighb_phenx_avg_p.bl.cm                           0.016  0.122  0.027  0.002
## overall.income.bl[>=50K & <100K]                  -0.098 -0.087 -0.022 -0.154
## overall.income.bl[<50k]                           -0.133 -0.200 -0.075 -0.138
## overall.income.bl[Don't Know or Refuse]           -0.107 -0.145 -0.061 -0.105
## sex.blFemale                                      -0.003 -0.023 -0.011  0.011
## reshist_addr1_no2_2016_aavg_bl.c533               -0.064 -0.105 -0.044  0.014
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.001 -0.018 -0.011  0.006
##                                                   hg..SC h..HSD h..<HD p..aHP
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                         0.507                     
## high.educ.bl< HS Diploma                           0.490  0.476              
## prnt.empl.blStay at Home Parent                   -0.017 -0.051 -0.113       
## prnt.empl.blUnemployed                            -0.009 -0.079 -0.129  0.176
## prnt.empl.blOther                                 -0.029 -0.011 -0.030  0.144
## neighb_phenx_avg_p.bl.cm                           0.055  0.048  0.062  0.029
## overall.income.bl[>=50K & <100K]                  -0.291 -0.188 -0.148 -0.022
## overall.income.bl[<50k]                           -0.396 -0.379 -0.387 -0.047
## overall.income.bl[Don't Know or Refuse]           -0.291 -0.293 -0.314 -0.090
## sex.blFemale                                       0.017  0.011 -0.005  0.004
## reshist_addr1_no2_2016_aavg_bl.c533                0.020 -0.001 -0.020  0.014
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.001 -0.006  0.019  0.006
##                                                   prn..U prn..O n___.. o..[&<
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                  0.140                     
## neighb_phenx_avg_p.bl.cm                           0.033 -0.007              
## overall.income.bl[>=50K & <100K]                  -0.017 -0.046  0.073       
## overall.income.bl[<50k]                           -0.097 -0.124  0.129  0.474
## overall.income.bl[Don't Know or Refuse]           -0.100 -0.111  0.089  0.391
## sex.blFemale                                       0.036  0.013  0.023  0.001
## reshist_addr1_no2_2016_aavg_bl.c533               -0.009 -0.008  0.107 -0.017
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.001 -0.015 -0.005  0.002
##                                                   o..[<5 o..KoR sx.blF r_1_2_
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                                            
## neighb_phenx_avg_p.bl.cm                                                     
## overall.income.bl[>=50K & <100K]                                             
## overall.income.bl[<50k]                                                      
## overall.income.bl[Don't Know or Refuse]            0.556                     
## sex.blFemale                                       0.000  0.001              
## reshist_addr1_no2_2016_aavg_bl.c533               -0.027 -0.003  0.005       
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.011  0.016 -0.001 -0.007
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -1.1649791 -0.3653236 -0.2726505  0.2194252 19.4199661 
## 
## Number of Observations: 23857
## Number of Groups: 21
anova(aggressive_zinb_r)
##                                                   numDF denDF  F-value p-value
## (Intercept)                                           1 14510 341.9834  <.0001
## reshist_addr1_pm252016aa_bl.c5                        1  9307   0.1523  0.6964
## interview_age.c9.y                                    1 14510  82.2311  <.0001
## race_ethnicity.bl                                     3  9307   2.4685  0.0601
## high.educ.bl                                          4  9307  21.8524  <.0001
## prnt.empl.bl                                          3  9307  13.1186  <.0001
## neighb_phenx_avg_p.bl.cm                              1  9307  81.7904  <.0001
## overall.income.bl                                     3  9307  10.0399  <.0001
## sex.bl                                                1  9307  88.7303  <.0001
## reshist_addr1_no2_2016_aavg_bl.c533                   1  9307   2.0241  0.1549
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y     1 14510   3.1019  0.0782

Assumption checking for ZINB Models

#Check outlier/residuals with this df
aggressive_res <- df_cc
aggressive_res$level1_resid.raw <- residuals(aggressive_zinb_r)
aggressive_res$level1_resid.pearson <- residuals(aggressive_zinb_r, type="pearson")
#Add predicted values (Yhat)
aggressive_res$cbcl_scr_syn_aggressive_r_predicted <- predict(aggressive_zinb_r,aggressive_res,type="response")
#Incidence
aggressive_res$incidence <- estimate.probability(aggressive_res$cbcl_scr_syn_aggressive_r, method="empirical")

#Plotting histogram of residuals, but may be skewed since using ZINB, so make sure to check below plots
hist(aggressive_res$level1_resid.pearson)

### Incidence vs. X’s Plots

#age
ggplot(aggressive_res,aes(incidence,interview_age)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

#pm2.5
ggplot(aggressive_res,aes(incidence,reshist_addr1_pm252016aa_bl)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

### Residuals vs Y (CBCL Outcome) Plot

plot(aggressive_res$level1_resid.pearson, aggressive_res$cbcl_scr_syn_aggressive_r)

### Residuals vs Yhat Plot

plot(aggressive_res$level1_resid.pearson, aggressive_res$cbcl_scr_syn_aggressive_r_predicted)

### Residuals vs Row Plot

plot(as.numeric(rownames(aggressive_res)),aggressive_res$level1_resid.pearson)

### Residuals vs X’s Plots

#age
ggplot(aggressive_res,aes(level1_resid.pearson,interview_age)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

#pm2.5
ggplot(aggressive_res,aes(level1_resid.pearson,reshist_addr1_pm252016aa_bl)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

Total Problems

CBCL + AP Longitudinal Models

Convergence Error with ZINB Model - thinking it’s b/c total problems might not be heavily zero inflated

hist(df_cc$cbcl_scr_syn_totprob_r)

hist(df_cc$cbcl_scr_syn_totprob_r[df_cc$eventname=="Baseline"])

hist(df_cc$cbcl_scr_syn_totprob_r[df_cc$eventname=="1-year"])

hist(df_cc$cbcl_scr_syn_totprob_r[df_cc$eventname=="2-year"])

# totprob_zinb_r <- glmm.zinb(cbcl_scr_syn_totprob_r ~ reshist_addr1_pm252016aa_bl*interview_age + race_ethnicity.1 + high.educ_bl+ prnt.empl.alltp  + neighb_phenx_avg_p + overall.income.alltp + sex, random = ~1|abcd_site/subjectid, 
#               zi_fixed = ~ reshist_addr1_pm252016aa_bl*interview_age + race_ethnicity.1 + high.educ_bl+ prnt.empl.alltp  + neighb_phenx_avg_p + overall.income.alltp + sex, zi_random = ~1|abcd_site/subjectid, data = df_cc)
# 
# summary(totprob_zinb_r)
# summary(totprob_zinb_r$zi.fit)
# anova(totprob_zinb_r)

#Trying just normal negative binomial model due to distribution of outcome
totprob_nb_r <- glmm.nb(cbcl_scr_syn_totprob_r ~ reshist_addr1_pm252016aa_bl.c5*interview_age.c9.y + race_ethnicity.bl + high.educ.bl+ prnt.empl.bl  + neighb_phenx_avg_p.bl.cm + overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533, random = ~1|abcd_site/subjectid, data = df_cc)
## Computational iterations: 6 
## Computational time: 0.481 minutes
summary(totprob_nb_r)
## Linear mixed-effects model fit by maximum likelihood
##   Data: df_cc 
##   AIC BIC logLik
##    NA  NA     NA
## 
## Random effects:
##  Formula: ~1 | abcd_site
##         (Intercept)
## StdDev:   0.1280292
## 
##  Formula: ~1 | subjectid %in% abcd_site
##         (Intercept) Residual
## StdDev:   0.8686449 1.212098
## 
## Variance function:
##  Structure: fixed weights
##  Formula: ~invwt 
## Fixed effects:  cbcl_scr_syn_totprob_r ~ reshist_addr1_pm252016aa_bl.c5 * interview_age.c9.y +      race_ethnicity.bl + high.educ.bl + prnt.empl.bl + neighb_phenx_avg_p.bl.cm +      overall.income.bl + sex.bl + reshist_addr1_no2_2016_aavg_bl.c533 
##                                                        Value  Std.Error    DF
## (Intercept)                                        2.6451853 0.05268093 14510
## reshist_addr1_pm252016aa_bl.c5                    -0.0004004 0.01105319  9307
## interview_age.c9.y                                -0.0209051 0.00798467 14510
## race_ethnicity.blHispanic                         -0.0565100 0.03097169  9307
## race_ethnicity.blBlack                            -0.2392913 0.03433506  9307
## race_ethnicity.blOther                            -0.0416651 0.03118715  9307
## high.educ.blBachelor                               0.0876493 0.02603209  9307
## high.educ.blSome College                           0.1263014 0.02987890  9307
## high.educ.blHS Diploma/GED                        -0.0542696 0.04209925  9307
## high.educ.bl< HS Diploma                          -0.0595857 0.05431965  9307
## prnt.empl.blStay at Home Parent                   -0.0033125 0.02651104  9307
## prnt.empl.blUnemployed                             0.1377946 0.04353720  9307
## prnt.empl.blOther                                  0.1929010 0.03828081  9307
## neighb_phenx_avg_p.bl.cm                          -0.1317072 0.01112065  9307
## overall.income.bl[>=50K & <100K]                   0.0964629 0.02639029  9307
## overall.income.bl[<50k]                            0.1784080 0.03324592  9307
## overall.income.bl[Don't Know or Refuse]            0.0479272 0.04161909  9307
## sex.blFemale                                      -0.1875365 0.01933200  9307
## reshist_addr1_no2_2016_aavg_bl.c533               -0.0051972 0.00265276  9307
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.0081013 0.00255056 14510
##                                                     t-value p-value
## (Intercept)                                        50.21144  0.0000
## reshist_addr1_pm252016aa_bl.c5                     -0.03623  0.9711
## interview_age.c9.y                                 -2.61815  0.0088
## race_ethnicity.blHispanic                          -1.82457  0.0681
## race_ethnicity.blBlack                             -6.96930  0.0000
## race_ethnicity.blOther                             -1.33597  0.1816
## high.educ.blBachelor                                3.36697  0.0008
## high.educ.blSome College                            4.22711  0.0000
## high.educ.blHS Diploma/GED                         -1.28909  0.1974
## high.educ.bl< HS Diploma                           -1.09695  0.2727
## prnt.empl.blStay at Home Parent                    -0.12495  0.9006
## prnt.empl.blUnemployed                              3.16498  0.0016
## prnt.empl.blOther                                   5.03910  0.0000
## neighb_phenx_avg_p.bl.cm                          -11.84348  0.0000
## overall.income.bl[>=50K & <100K]                    3.65524  0.0003
## overall.income.bl[<50k]                             5.36631  0.0000
## overall.income.bl[Don't Know or Refuse]             1.15157  0.2495
## sex.blFemale                                       -9.70083  0.0000
## reshist_addr1_no2_2016_aavg_bl.c533                -1.95918  0.0501
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  -3.17629  0.0015
##  Correlation: 
##                                                   (Intr) rs_1_252016_.5 in_.9.
## reshist_addr1_pm252016aa_bl.c5                    -0.374                      
## interview_age.c9.y                                -0.265  0.339               
## race_ethnicity.blHispanic                         -0.026 -0.066          0.004
## race_ethnicity.blBlack                            -0.019 -0.020          0.007
## race_ethnicity.blOther                            -0.082 -0.015          0.004
## high.educ.blBachelor                              -0.178  0.002          0.000
## high.educ.blSome College                          -0.120 -0.012          0.003
## high.educ.blHS Diploma/GED                        -0.072 -0.006          0.005
## high.educ.bl< HS Diploma                          -0.027 -0.015         -0.002
## prnt.empl.blStay at Home Parent                   -0.081 -0.015          0.001
## prnt.empl.blUnemployed                            -0.025 -0.001          0.000
## prnt.empl.blOther                                 -0.038  0.003          0.007
## neighb_phenx_avg_p.bl.cm                          -0.174  0.047         -0.003
## overall.income.bl[>=50K & <100K]                  -0.116 -0.016          0.001
## overall.income.bl[<50k]                           -0.055 -0.025         -0.001
## overall.income.bl[Don't Know or Refuse]           -0.055 -0.027         -0.002
## sex.blFemale                                      -0.174 -0.004          0.003
## reshist_addr1_no2_2016_aavg_bl.c533               -0.500 -0.247          0.004
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.228 -0.392         -0.866
##                                                   rc_t.H rc_t.B rc_t.O hgh..B
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                             0.351                     
## race_ethnicity.blOther                             0.287  0.259              
## high.educ.blBachelor                              -0.019 -0.013  0.000       
## high.educ.blSome College                          -0.112 -0.085 -0.024  0.455
## high.educ.blHS Diploma/GED                        -0.144 -0.145 -0.006  0.333
## high.educ.bl< HS Diploma                          -0.165 -0.074 -0.009  0.263
## prnt.empl.blStay at Home Parent                    0.043  0.091  0.018 -0.025
## prnt.empl.blUnemployed                             0.011 -0.040  0.010 -0.009
## prnt.empl.blOther                                  0.040  0.009 -0.012 -0.013
## neighb_phenx_avg_p.bl.cm                           0.028  0.134  0.039 -0.003
## overall.income.bl[>=50K & <100K]                  -0.091 -0.063 -0.015 -0.173
## overall.income.bl[<50k]                           -0.143 -0.184 -0.081 -0.159
## overall.income.bl[Don't Know or Refuse]           -0.095 -0.126 -0.060 -0.100
## sex.blFemale                                      -0.008 -0.018 -0.017  0.014
## reshist_addr1_no2_2016_aavg_bl.c533               -0.058 -0.089 -0.034  0.014
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.000 -0.001 -0.002 -0.001
##                                                   hg..SC h..HSD h..<HD p..aHP
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                         0.497                     
## high.educ.bl< HS Diploma                           0.408  0.377              
## prnt.empl.blStay at Home Parent                   -0.012 -0.048 -0.093       
## prnt.empl.blUnemployed                            -0.009 -0.068 -0.096  0.146
## prnt.empl.blOther                                 -0.033 -0.012 -0.020  0.157
## neighb_phenx_avg_p.bl.cm                           0.061  0.055  0.050  0.027
## overall.income.bl[>=50K & <100K]                  -0.276 -0.172 -0.114 -0.032
## overall.income.bl[<50k]                           -0.416 -0.367 -0.309 -0.054
## overall.income.bl[Don't Know or Refuse]           -0.251 -0.240 -0.221 -0.077
## sex.blFemale                                       0.022  0.016 -0.004 -0.005
## reshist_addr1_no2_2016_aavg_bl.c533                0.019  0.004 -0.019  0.007
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y -0.001 -0.001  0.003  0.004
##                                                   prn..U prn..O n___.. o..[&<
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                  0.130                     
## neighb_phenx_avg_p.bl.cm                           0.022  0.003              
## overall.income.bl[>=50K & <100K]                  -0.015 -0.048  0.081       
## overall.income.bl[<50k]                           -0.100 -0.137  0.150  0.504
## overall.income.bl[Don't Know or Refuse]           -0.077 -0.097  0.083  0.360
## sex.blFemale                                       0.020  0.019  0.026 -0.006
## reshist_addr1_no2_2016_aavg_bl.c533               -0.010 -0.002  0.102 -0.010
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.002 -0.006  0.001 -0.001
##                                                   o..[<5 o..KoR sx.blF r_1_2_
## reshist_addr1_pm252016aa_bl.c5                                               
## interview_age.c9.y                                                           
## race_ethnicity.blHispanic                                                    
## race_ethnicity.blBlack                                                       
## race_ethnicity.blOther                                                       
## high.educ.blBachelor                                                         
## high.educ.blSome College                                                     
## high.educ.blHS Diploma/GED                                                   
## high.educ.bl< HS Diploma                                                     
## prnt.empl.blStay at Home Parent                                              
## prnt.empl.blUnemployed                                                       
## prnt.empl.blOther                                                            
## neighb_phenx_avg_p.bl.cm                                                     
## overall.income.bl[>=50K & <100K]                                             
## overall.income.bl[<50k]                                                      
## overall.income.bl[Don't Know or Refuse]            0.485                     
## sex.blFemale                                      -0.008  0.006              
## reshist_addr1_no2_2016_aavg_bl.c533               -0.022 -0.005  0.000       
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y  0.001  0.002  0.000 -0.004
## 
## Standardized Within-Group Residuals:
##        Min         Q1        Med         Q3        Max 
## -2.5189022 -0.6176406 -0.0744057  0.4578181  4.5302533 
## 
## Number of Observations: 23857
## Number of Groups: 
##                abcd_site subjectid %in% abcd_site 
##                       21                     9345
anova(totprob_nb_r)
##                                                   numDF denDF  F-value p-value
## (Intercept)                                           1 14510 7133.859  <.0001
## reshist_addr1_pm252016aa_bl.c5                        1  9307    0.136  0.7121
## interview_age.c9.y                                    1 14510  115.715  <.0001
## race_ethnicity.bl                                     3  9307    2.918  0.0328
## high.educ.bl                                          4  9307   25.732  <.0001
## prnt.empl.bl                                          3  9307   17.297  <.0001
## neighb_phenx_avg_p.bl.cm                              1  9307  153.599  <.0001
## overall.income.bl                                     3  9307   10.571  <.0001
## sex.bl                                                1  9307   94.135  <.0001
## reshist_addr1_no2_2016_aavg_bl.c533                   1  9307    3.887  0.0487
## reshist_addr1_pm252016aa_bl.c5:interview_age.c9.y     1 14510   10.089  0.0015

Assumption checking for ZINB Models

#Check outlier/residuals with this df
totprob_res <- df_cc
totprob_res$level1_resid.raw <- residuals(totprob_nb_r)
totprob_res$level1_resid.pearson <- residuals(totprob_nb_r, type="pearson")
#Add predicted values (Yhat)
totprob_res$cbcl_scr_syn_totprob_r_predicted <- predict(totprob_nb_r,totprob_res,type="response")
#Incidence
totprob_res$incidence <- estimate.probability(totprob_res$cbcl_scr_syn_totprob_r, method="empirical")

#Plotting histogram of residuals, but may be skewed since using nb, so make sure to check below plots
hist(totprob_res$level1_resid.pearson)

### Incidence vs. X’s Plots

#age
ggplot(totprob_res,aes(incidence,interview_age)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

#pm2.5
ggplot(totprob_res,aes(incidence,reshist_addr1_pm252016aa_bl)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

### Residuals vs Y (CBCL Outcome) Plot

plot(totprob_res$level1_resid.pearson, totprob_res$cbcl_scr_syn_totprob_r)

### Residuals vs Yhat Plot

plot(totprob_res$level1_resid.pearson, totprob_res$cbcl_scr_syn_totprob_r_predicted)

### Residuals vs Row Plot

plot(as.numeric(rownames(totprob_res)),totprob_res$level1_resid.pearson)

### Residuals vs X’s Plots

#age
ggplot(totprob_res,aes(level1_resid.pearson,interview_age)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

#pm2.5
ggplot(totprob_res,aes(level1_resid.pearson,reshist_addr1_pm252016aa_bl)) + geom_point(color = "black") + geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'